Answer the question
In order to leave comments, you need to log in
How correctly in afterSave to execute insert in the linking table?
Good afternoon, I have 3 tables, I leave the key fields:
product (code, name);
l_product_22_params(code_1, code_2); [ // analogue of product_code, params_code ]
params (code,name)
There is a link in the Product class:
[PHP]
'params'=>array(self::MANY_MANY, 'Params',
'l_product_22_params(CODE_1, CODE_2)'),
[ /PHP]
in _form checkboxed the data from the params table:
[PHP]
<?php echo $form->labelEx($model,'NAME'); ?>
<?php echo $form->textField($model,'NAME',array('size'=>45,'maxlength'=>45)); ?>
<?php echo $form->error($model, 'NAME'); ?>
<?php echo $form->checkBoxList($model, 'params', CHtml::listData(Params::model()->findAll(), 'CODE', 'NAME')); ?>
[/PHP]
in the aftersave method, I know that the code of the last loaded record in the product will seem to be $this->CODE, but how to pull out an array of checked checkboxes and run through foreach and do it in the l_product_22_params save table, please tell me!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question