Problem With Collecting Tabular Input.

I want to know why $item->attributes = $_POST[‘Member’][$i]; won’t work.Any body please help me.

In my controller.

        $items = $this->getItemsToUpdate($id);

        if (isset($_POST['Member'])) {

            foreach ($items as $i => $item) {

                if (isset($_POST['Member'][$i]))  {

                        $item->attributes = $_POST['Member'][$i];// This won't work,product_print won't update when saved.

                        $item->product_print=$_POST['Member'][$i]['product_print'];// This will work,product_print will be     update when saved





        $this->render('view', array(

            'model' => $this->loadModel($id),

            'items' => $items,



    public function getItemsToUpdate($id) {

        $items = Member::model()->findAll('groupid=' . $id);

        return $items;


In my view.

<?php foreach($items as $i=>$item): ?>

<?php echo CHtml::activeTextField($item,"[$i]product_print"); ?>

<?php endforeach; ?>

You need to make sure that product_print has a validation rule in the current scenario. If any value is acceptable, you can use the ‘safe’ rule.

array('product_print', 'safe'),

Thank you very much Keith,It 's working now. :rolleyes:

Compare rule in tabular input is not working.

Model class

class CustomReference extends Reference {

    public $retypeEmail;

    public function rules() {

        return(array_merge(parent::rules(), array(

                    array('retypeEmail', 'safe'),

                    array('retypeEmail', 'email'),

                    array('retypeEmail', 'compare', 'compareAttribute' => 'rf_email'),



    public function attributeLabels() {


            'rf_code' => Yii::t('app', 'Rerence Code'),

            'rf_contact' => Yii::t('app', 'Reference Contact'),

            'rf_description' => Yii::t('app', 'Reference Description'),

            'rf_phone' => Yii::t('app', 'Reference Phone'),

            'rf_cellphone' => Yii::t('app', 'Reference Cellphone'),

            'rf_email' => Yii::t('app', 'Reference Email'),

            'rf_sp_code' => Yii::t('app', 'Reference Sp Code'),

            'rf_creationDate' => Yii::t('app', 'Reference Creation Date'),

            'rf_updateDate' => Yii::t('app', 'Reference Update Date'),

            'rf_user' => Yii::t('app', 'Reference User'),

            'rf_type' => Yii::t('app', 'Reference Type'),

            'retypeEmail' => Yii::t('magistral', 'Retype Reference Email'),





foreach ($references as $reference) {            

                if ($i % 2 == 0)

                    echo '<div class="span12 margin-bottom-50">';

                echo '<div class="span6">';

                echo $form->textFieldRow($reference, "[$i]rf_contact", array('hint' => Yii::t('magistral', 'Introduce the name contact of the company'), 'class' => 'width-80-percent', 'labelOptions' => array('class' => 'bold-text')));

                echo $form->maskedTextFieldRow($reference, "[$i]rf_phone", '(+999)999-9999999)', array('hint' => Yii::t('magistral', 'Introduce the phone number like (+999)999-999999'), 'class' => 'width-80-percent', 'labelOptions' => array('class' => 'bold-text')));

                echo $form->textFieldRow($reference, "[$i]rf_email", array('hint' => Yii::t('magistral', 'Introduce the email like'), 'class' => 'width-80-percent', 'labelOptions' => array('class' => 'bold-text')));

                echo $form->textFieldRow($reference, "[$i]retypeEmail", array('hint' => Yii::t('magistral', 'Retype the email like'), 'class' => 'width-80-percent', 'labelOptions' => array('class' => 'bold-text')));

                echo $form->hiddenField($reference, "[$i]rf_type", array());

                echo '</div>';

                if ($i % 2 != 0)

                    echo '</div>';