Create pivot with value using inline editing

Create pivot with value using inline editing

DTUser560425DTUser560425 Posts: 1Questions: 1Answers: 0


I'm leftjoining a table to a pivot table with a price value, as expected items without an entry in the pivot table have no value in the price column.

Would it be possible to create an entry in the pivot table when an empty price column is filled out using inline editing?
From what I can tell this isn't standard and I'm having no luck trying to use the 'preEdit' event to do it manually.

$data = Editor::inst( $db, 'items', 'id' )
        Field::inst( '' ),
        Field::inst( '' ),
        Field::inst( 'items.code' ),
        Field::inst( 'items.product_code' ),
        Field::inst( 'item_prices.price'),
    ->leftJoin( 'item_prices', '', '=', 'item_prices.item_id' )
    ->process( $_POST )


  • allanallan Posts: 53,362Questions: 1Answers: 8,249 Site admin

    Currently no - I'm afraid not. As you say, the only way to do this is with a server-side event such as postCreate.

    In this case perhaps:

    ->on('postCreate', function ($editor, $id, $values, $row) }
          'item_id' => $id,
          'price' => $values['item_prices']['price']

    This is the reference doc for the database class btw.

    A similar approach could be done for inline editing if the links rows might not be there, or if the joined column can be inline edited (see the Database->push() method for an upsert).


Sign In or Register to comment.