Thanks for your valuable inputs.
Joblo, on 11 November 2011 - 02:37 AM, said:
1. Lets giix do the job for the form/controller for the order and the categories related to the order (checkboxes).
Comment the tbl_order_categories before creating the CRUD with the help of giix, so that the code for OrderProduct in the form/controller will not be created.
2. Add the code for the multimodelform (= detail = order_product) manually.
Add a 'getMultiModelForm' method to your OrderProduct model.
Something like this:
- Add the multimodelform widget in the form:
The '$member' from the documentation is your OrderProduct model.
- Add the multimodelform code to save/validate the multimodel data similar to the one in the documentation.
$model = Order, $member = $orderProduct ($validatedOrderProduct ...).
Maybe try first with 'MultiModelForm::save' only and add 'MultiModelForm::validate' later.
- Hint: do var_dump in the actionCreate to see whats comming in, will be validated ...
Your suggestion works fine for actionCreate. But for actionUpdate MultiModelForm code would require an update...
Since my tbl_order_products primary key is a composite key (order_id, product_id) MultiModelForm code fails when extracting the primary key from this table:
PHP Error Illegal offset type C:\...\extensions\multimodelform\MultiModelForm.php(523) $pkValue = $model->primaryKey; if (!empty($pkValue)) { $pkName = $model->primaryKey(); if (empty($pkName)) $pkName = $model->tableSchema->primaryKey; -> $result = array($pkName => $pkValue); }
Is this a bug or your extension is not supposed to work with composite keys?
Can you please provide me a workaround for this?
Thanks for your support,
A.Miguel