Answer the question
In order to leave comments, you need to log in
How to set the correct validator for a simple radio button in yii?
Good day!
I have a form from CFormModel . There are many fields in the form, and all of them are validated except for the sex (gender) field of type radio .
There are only 2 radio buttons - male , female .
For sex, the rules are:
public function rules()
{
return array(
array(' ... , sex'=>'required'),
array('sex', 'length', 'max'=>6),
);
}
php echo $form->radioButtonList($qForm,'sex',array(
'male'=>'male',
'female'=>'female'
));
Answer the question
In order to leave comments, you need to log in
Look at the html form. Can compare with those that work. maybe the name is wrong. Check what the form submits to see if there is any value there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question