Hi,
I don't think the NotEmpty validator is ever called, because there is no empty value in the multiOptions array.
If you want to see the message, you should add '' => '' as the first item in the array.
Regards,
Jachim Coudenys
-----Oorspronkelijk bericht-----
Van: Thomas List [mailto:thomaslist@hotmail.com]
Verzonden: maandag 31 januari 2011 22:25
Aan: fw-mvc-help@lists.zend.com; fw-mvc@lists.zend.com
Onderwerp: [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
--
This email was Anti Virus scanned.
没有评论:
发表评论