Can not get Value on preEdit Event
Can not get Value on preEdit Event

I want to set total_price from quanity * unit_price on preEdit event. I am using inline editing. But i can not get the quantity and unit_price value.
Here is my code:
Editor::inst($db, 'carts')
->fields(
Field::inst('products.name'),
Field::inst('carts.quantity'),
Field::inst('carts.unit_price'),
Field::inst('carts.total_price'),
Field::inst('carts.product_id')
->options(Options::inst()
->table('products')
->value('id')
->label('name')
)
)
->on( 'preEdit', function ( $editor, $id, $values ) {
$qty = $values['carts.quantity']*$values['carts.unit_price'];
$editor
->field( 'carts.total_price' )
->setValue($qty );
} )
->leftJoin("products", "carts.product_id", "=", "products.id")
->process($_POST)
->debug(true)
->json();
When i hit enter key after change value, i got this error: Undefined index: carts.quantity. What is wrong?
This discussion has been closed.
Replies
Use
$values['carts']['quantity']
. Its a 2D array that gets submitted.Allan
Done. Thanks Allan.