E
E
EVOSandru62014-11-14 05:14:43
Yii
EVOSandru6, 2014-11-14 05:14:43

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

1 answer(s)
D
Dmytro Karpovych, 2014-11-20
@ZAYEC77

Try

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question