Collect In $_Post Many Models Info For The Same Key/columns

HI all,

Here is the problematic situation : In a form, in order to update a record, I use three different models from another table. But these models are all from the same table.

So when I submit my form, in my $_POST I have only one model info in the POST array corresponding to the table instead of 3… Submittion takes only the last record edit in form. Indeed I edit the same key name for the models…

I don’t really know how to collect the multiple model info which corresponds to the same key but for different models.

Can you share the code?

Well, a solution should be to create public variables in the table activeRecord of my 3 models then edit and hand out the variables to the 3 models before to save them…

But sounds very dirty =(

Controller edit action starts with :


    $mod_level_1 = ModLevel::model()->findByAttributes(array('mod_id'=>$model->id,'out_id'=>'3'));

    $mod_level_2 = ModLevel::model()->findByAttributes(array('mod_id'=>$model->id,'out_id'=>'1'));

    $mod_level_3 = ModLevel::model()->findByAttributes(array('mod_id'=>$model->id,'out_id'=>'2'));







then in form :

<div class="row" disabled="disabled">

		<?php echo $form->labelEx($model,'name'); ?>

		<?php echo  $form->textField($model,'name',array('rows'=>1, 'cols'=>50));?>



  <div class="row">

		<?php echo $form->labelEx($mod_level_1,'level'); ?>

    <?php echo $form->dropDownList($mod_level_1,'level',

    array('1','2','3','4')); ?>



  <div class="row">

		<?php echo $form->labelEx($mod_level_3,'level'); ?>

    <?php echo $form->dropDownList($mod_level_3,'level',

    array('1','2','3','4')); ?>



  	<div class="row">

		<?php echo $form->labelEx($mod_level_2,'level'); ?>

    <?php echo $form->dropDownList($mod_level_2,'level',

    array('1','2','3','4')); ?>


With that… I would have in $_POST only the value for mod_level_2

It is because that in each of your dropdown list the name of filed is level.

Try it with as

    <?php echo $form->dropDownList($mod_level_2,'level[]',

    array('1','2','3','4')); ?>

It works =) Thanks for reply ;)

I didn’t know I could use something else than table attributes type and name for form inputs.