FormModel validation failes for multiselect fields

Hi,

I have a set of checkboxes that are loaded dynamically:




<?php echo CHtml::checkBoxList('facilities', $form['facilities'], $this->getAttributes('Facility'), array('separator'=>' ')); ?>



I added this rule to the form model to validate the selected values (which are supposet to be numbers):




public function rules()

{

    return array(

        array('facilities', 'numerical'),

        // the rest of the rules...

    );

}



after submitting the form I get the "Facilities must be a number" error.

what am I doing wrong?

Hi

can you check what you have a get on Controller action print_r($_POST) or print_r($_GET)

I think you have receive " on " so far this error " Facilities must be a number "

Otherwise comment // array(‘facilities’, ‘numerical’),

Thanks

Thanks for your answer.

the form values are sent to the server as they should. they are as well loaded into the form model as an array of checkbox values.

for a workaround I added my own validator in the model:




public function multi_int($field)

{

    $value = (array) $this->$field;

    $value = array_map('intval', $value);

    $this->$field = $value;

}



I just want to know whether Yii can already validate this kind of input values or I should use custom validators.