CHtml::Yii中的radioButtonList验证

CHtml::Yii中的radioButtonList验证,yii,yii-chtml,Yii,Yii Chtml,我在Yii项目中的一个表单中使用了Chtml 我已经实现了这种形式的radioButton,即 <?php echo CHtml::radioButtonList('asset', 'asset', $listAsset, array('uncheckValue'=>null));?> 如何对此进行验证?我们不希望在表单中使用模型名称,请尝试以下步骤 指定属性值后,可以将post值指定给模型属性 在模型的规则函数中指定验证后,可以使用以下步骤 示例: $model-

我在Yii项目中的一个表单中使用了Chtml

我已经实现了这种形式的radioButton,即

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


如何对此进行验证?

我们不希望在表单中使用模型名称,请尝试以下步骤

指定属性值后,可以将post值指定给模型属性

在模型的规则函数中指定验证后,可以使用以下步骤

示例:

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

$model->asset = $_POST['asset'];

使用模型名。提交表单时,将验证模型属性并返回错误(如果有)。请看一下这个,然后我想你必须使用jquery。你不想在表单中使用模型名吗?@Rafay我使用了客户端验证。谢谢你提供的信息。