Deleting values when editing

Deleting values when editing

ManuelWennerManuelWenner Posts: 16Questions: 2Answers: 1

Hey Guys,

i have a 1:n relationship and using JOIN class. Everything works fine. The values from the joined table i just want to display, so i don't added them in the "fields" part of "editor = new $.fn.dataTable.Editor( {" After editing a value from the parent join table, the values from the joined tables are deleted / empty. So i tried to use "->set(false)" but made no difference.
I am doing an n:m join too and here it works perfect, even without "->set(false)"

I also tried to set the field type "readonly". In this case i got an error "update is not a function".

Can anyone help me?

Editor::inst( $db, 'abs', 'abs.id' )
// Editor::inst( $db, 'abs')
    ->fields(
        Field::inst( 'abs.id' ),
        Field::inst( 'abs.number' )->validator( 'Validate::notEmpty' ),
     )
    ->join(
        Join::inst( 'block', 'array' )
            ->join( 'id', 'blockAbId' )
            ->fields(
                Field::inst( 'blockId' )
                    ->validator( 'Validate::required' )
                    ->options( 'block', 'blockId', 'blocknummer' )->set(false),
                Field::inst( 'blocknummer' )->set(false)
                //,           
            )
    )
    ->join(
        Join::inst( 'delivery', 'array' )
            ->join(
                array( 'abId', 'abId' ),
                array( 'deliveryId', 'deliveryId' ),
                'abDelivery'
            )
            ->fields(
                Field::inst( 'deliveryId' )
                    ->validator( 'Validate::required' )
                    ->options( 'delivery', 'deliveryId', 'bezeichnung' )
                    ->set(false),
                Field::inst( 'bezeichnung' )
                    ->set(false),
                Field::inst( 'betrag' )
                    ->set(false)
            )
    )

This question has an accepted answers - jump to answer

Answers

  • ManuelWennerManuelWenner Posts: 16Questions: 2Answers: 1
    Answer ✓

    Ok fixed it :) The solution was to add "->set(false)" for the JOIN::inst and not for every field in "->fields".

    It should look like this

    Editor::inst( $db, 'abs', 'abs.id' )
    // Editor::inst( $db, 'abs')
        ->fields(
            Field::inst( 'abs.id' ),
            Field::inst( 'abs.number' )->validator( 'Validate::notEmpty' ),
         )
        ->join(
            Join::inst( 'block', 'array' )
                ->join( 'id', 'blockAbId' )
                ->fields(
                    Field::inst( 'blockId' )
                        ->validator( 'Validate::required' )
                        ->options( 'block', 'blockId', 'blocknummer' ),
                    Field::inst( 'blocknummer' )
                    //,          
                )
        )
        ->join(
            Join::inst( 'delivery', 'array' )
                ->join(
                    array( 'abId', 'abId' ),
                    array( 'deliveryId', 'deliveryId' ),
                    'abDelivery'
                )
                ->fields(
                    Field::inst( 'deliveryId' )
                        ->validator( 'Validate::required' )
                        ->options( 'delivery', 'deliveryId', 'bezeichnung' ),
                    Field::inst( 'bezeichnung' ),
                    Field::inst( 'betrag' )
                )
               ->set(false)
        )
    
  • allanallan Posts: 61,777Questions: 1Answers: 10,112 Site admin

    Hi,

    Good to hear you found the solution. Thanks for posting back.

    Allan

This discussion has been closed.