E
E
EVOSandru62015-02-02 09:50:56
Yii
EVOSandru6, 2015-02-02 09:50:56

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),
        );
}

In the form I display the radio buttons in this way:
php echo $form->radioButtonList($qForm,'sex',array(
    'male'=>'male',
    'female'=>'female'
));

For some reason, when I click on submit, an error appears on the form: It is
necessary to fill in the "Gender" field.
Even though I selected the radio button as if I hadn't clicked anywhere, what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2015-02-08
@webinar

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 question

Ask a Question

731 491 924 answers to any question