2011年1月31日星期一

[fw-mvc] Form Validators

I am trying to write custom form validation for a multiselect box. I was easily able to write validators for other text boxes, but I tried to create a validator for the select box, and it still returns the system error message. Here is the code and I want to check if the array is empty. Looking at again now, it doesn't look like I'm checking the array correctly.

$this -> addElement( 'multiselect', 'incentiveId', array(
'label' => '<h1>Please select energy topics of interest:</h1>',
'escape' => false,
'required' => true,
'multioptions' => array(
'5' => 'Energy Efficiency',
'6' => 'Wind Technology',
'7' => 'Geothermal System',
'8' => 'Solar Technology',
'9' => 'All'
),
'validators' => array(array('validator'=>'NotEmpty', true,
array('messages'=>array('isEmpty'=>'Please Select A Type Of Incentive')))),
'decorators' => array(
'ViewHelper',
'Errors',
array( 'HtmlTag', array( 'tag' => 'dd' ) ),
array( 'Label', array( 'tag' => 'dt', 'escape' => false) )
)
));


A pointer in the right direction would greatly be appreciated, since there don't seem to correct answers from websites.

Regards,
Thomas List

没有评论: