2011年1月31日星期一

Re: [fw-mvc] Form Validators

Something like this.

pastie for a better view of it
http://pastie.org/1516522

On Mon, 2011-01-31 at 16:24 -0500, Thomas List wrote:
> 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
>

--
MvH
Antoine Hedgecock <antoine@pmg.se>
PMG Media Group AB

没有评论: