Wednesday, January 28, 2009

Re: how to display validation error messages

FormHelper will display the error. But it seems to depend upon how you
define your input. Sometimes, you need to explicitly set the error
element. I still haven't figured it out. Whenever I run into this, I
just add the following wherever I need it:

$form->error(FIELD_NAME);

Where FIELD_NAME, in this case, would be 'district'.


On Thu, Jan 29, 2009 at 1:04 AM, forrestgump <vikhyat86@gmail.com> wrote:
>
> Hey guys,
> Needed help with this one...seems as though it was never answered
> anywhere in the group so i think it will help a lot of people-
>
> I have a validation criteria in my Model defined as below:
> class District extends AppModel
> {
>
> var $validate = array(
> 'district' => array(
> 'rule' => 'alphaNumeric',
> 'message' => 'Error: Empty District Field',
> 'allowEmpty' => false
> )
>
> );
>
> }
>
> Now when the user inputs an empty district field, the save does not
> take place as expected. what I would like to do is to somehow print
> the 'message' --- 'Error: Empty District Field', that i supplied in
> the array above. I was expecting Cake to do it automatically but it
> seems iam wrong. Will appreciate any help given.
>
> Thanx again,
> Forrestgump
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: