Textfield Value Is Blank

Here’s the scenario: I was working on the form with textfield, a button, a checkboxlist(which will be filled with textbox value). But the problem is when enter something in the textfield, the entry is added in the checkboxlist, but value is not showing(meaning it’s a checkbox without name/label). I tested it with firebug. it is showing the value of textfield in the POST. But in the model it is showing blank. Here is the code.

View file

============================================

<?php /** @var BootActiveForm $form */

$form = $this->beginWidget(‘bootstrap.widgets.TbActiveForm’, array(

'id'=&gt;'testForm',


'htmlOptions'=&gt;array('class'=&gt;'well'),


'enableClientValidation'=&gt;true,


'clientOptions'=&gt;array(


	'validateOnSubmit'=&gt;true,


),


)); ?&gt;

<?php echo $form->textFieldRow($model, ‘text1’, array(‘class’=>‘span3’)); ?><br>

<?php echo CHtml::button(‘check’, array(‘submit’ => array(‘test/gridtest1’))); ?>

<div class="row-fluid">

&lt;?php echo CHtml::activeCheckBoxList(&#036;model,'wh1',&#036;list,array('style'=&gt;'float:left')); ?&gt; 

</div>

//<?php foreach ($list as $value) {

// echo $value."<->";

//} ?>

<?php $this->endWidget(); ?>

============================================

Model file

============================================

<?php

/**

  • This is the model class for table "actions".

  • The followings are the available columns in table ‘actions’:

  • @property integer $id

  • @property string $action

*/

class Actions extends CActiveRecord

{

public &#036;text1;


public &#036;wh1;


/**


 * @return string the associated database table name


 */


public function tableName()


{


	return 'actions';


}





/**


 * @return array validation rules for model attributes.


 */


public function rules()


{


	// NOTE: you should only define rules for those attributes that


	// will receive user inputs.


	return array(


		//array('action', 'required'),


		//array('action', 'length', 'max'=&gt;50),


		// The following rule is used by search().


		// @todo Please remove those attributes that should not be searched.


		array('id, action', 'safe', 'on'=&gt;'search'),


	);


}





public static function model(&#036;className=__CLASS__)


{


	return parent::model(&#036;className);


}


   


    public function addAction()


    {


        


        if(&#036;this-&gt;text1 === &quot;&quot;)


        {


            &#036;this-&gt;addError('text1','errororororororororororor....');


        }


        else


        {


            


            //&#036;sql=&quot;insert into actions(action) values('&quot;.&#036;this-&gt;text1.&quot;');&quot;;


            &#036;sql = &quot;INSERT INTO `actions`(`action`) VALUES ('&#036;this-&gt;text1')&quot;;


            &#036;insert = Yii::app()-&gt;db-&gt;createCommand(&#036;sql);


            if(&#036;insert-&gt;execute() == 1){


               &#036;cmd=  Yii::app()-&gt;db-&gt;createCommand();


            &#036;cmd-&gt;select=&quot;*&quot;;


            &#036;cmd-&gt;from=&quot;actions&quot;;


        &#036;data=&#036;cmd-&gt;query();


        &#036;list = array();    


            foreach(&#036;data as &#036;checkbox)


            {


               &#036;list[]= &#036;checkbox[&quot;action&quot;];


            }


            


            return &#036;list;


               


            }


        else {


            echo &quot;Error occured......&quot;;


                    


            }


        }


            


            


    }

}

==========================================================================

Controller code

==========================================================================

<?php

class TestController extends Controller

{

public &#036;defaultAction = 'gridtest1';


 public function actiongridtest1()


    {


        


        &#036;model = new Actions();


        


        &#036;data = &#036;model-&gt;addAction();


        &#036;msg =&quot;&quot;;


        &#036;this-&gt;render('gridtest1',array('model'=&gt;&#036;model,'msg'=&gt;&#036;msg,'list'=&gt;&#036;data));





   }

}