Search code examples
yiiyii-chtml

CHtml::radioButtonList validation in Yii


Im using Chtml for one of my form in my Yii project.

I have implemented radioButton in that form , i.e

   <?php echo CHtml::radioButtonList('asset', 'asset', $listAsset, array('uncheckValue'=>null));?>

how can I do validation for this?


Solution

  • we don't want use model name in form mean try the following steps

    after assign the attribute values you can assign the post values to model attributes

    once you specified the validation in MODEL's rules function, you can use the following steps.

    example :

    $model->attributes = $_POST['model']; //if you use model name in other fields  
    
    $model->asset = $_POST['asset'];