Editing multiple joined tables' fields

Editing multiple joined tables' fields

ali.riza.barzoali.riza.barzo Posts: 1Questions: 1Answers: 0
edited January 2018 in Free community support

Hello I have 4 tables. SW_DUMP, SITE_WORK, EQUIPMENT and PROJECT.
I want to show all columns of SW_DUMP. Additionally there is a column named WORK_ID in SW_DUMP and it points to SITE_WORK. I also want to edit the columns coming from SITE_WORK via Editor.
I managed to change SW_DUMP columns but could not update SITE_WORK columns. Here is the Editor instance:

Editor::inst( $db, 'SW_DUMP' )
    ->fields(
        Field::inst( 'SW_DUMP.ID' ),
        Field::inst( 'SW_DUMP.LOAD_START' ),
        Field::inst( 'SW_DUMP.LOAD_END' ),
        Field::inst( 'SW_DUMP.DRAFT_START' ),
        Field::inst( 'SW_DUMP.DRAFT_END' ),
        Field::inst( 'SW_DUMP.TARGET_GRID' )
            ->options( Options::inst()
                ->table( 'GRIDS' )
                ->value( 'ID' )
                ->label( 'NUMBER' )
            ),
        Field::inst('GRIDS.NUMBER'),
        Field::inst( 'SW_DUMP.WORK_ID' )
            ->options( Options::inst()
                ->table( 'SITE_WORK' )
                ->value( 'ID' )
                ->label( 'ID' )
            ),
        Field::inst('SITE_WORK.ID'),
        Field::inst('SITE_WORK.DATE'),
        Field::inst('SITE_WORK.START'),
        Field::inst('SITE_WORK.END'),
        Field::inst('SITE_WORK.NOTES'),
        Field::inst('SITE_WORK.EQUIPMENT')
            ->options(Options::inst()
                ->table('EQUIPMENT')
                ->value('ID')
                ->label('NAME')
            ),
        Field::inst('EQUIPMENT.NAME'),
        Field::inst('GRIDS.PROJECT')
            ->options(Options::inst()
                ->table('PROJECT')
                ->value('ID')
                ->label('NAME')
            )->set(false),
        Field::inst('PROJECT.NAME')
    )
    ->leftJoin( 'GRIDS', 'GRIDS.ID', '=', 'SW_DUMP.TARGET_GRID' )
    ->leftJoin( 'SITE_WORK', 'SITE_WORK.ID', '=', 'SW_DUMP.WORK_ID' )
    ->leftJoin( 'PROJECT', 'PROJECT.ID', '=', 'GRIDS.PROJECT' )
    ->leftJoin( 'EQUIPMENT', 'SITE_WORK.EQUIPMENT', '=', 'EQUIPMENT.ID' )

What should be done in order to edit SITE_WORK columns?
Thanks

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    You need to include the SITE_WORK.ID value in your client-side Editor field list (use hidden). That will let Editor update the joined table.

    Allan

This discussion has been closed.