Sunday, March 1, 2009

Re: customizing error messages from form helper

I guess you could extend the formHelper and array_merge 'error' =>
'false' into the options and then a $this->error() call after it. You
could also throw in the conditional if ($this->isFieldError('field')).

-Corie

On Mar 1, 3:29 pm, horatio <bnab...@says.mu> wrote:
> thanks corie.
>
> is there any way you know of to do this globally so i dont have to repeat
> the code so often?
>
>
>
> corie wrote:
>
> > You can change the class 'error-message' to whatever you want by
> > setting it in the options array of your $form->input call:
>
> > $form->input('field', array('error' => array('class' => 'custom-error-
> > class')));
>
> > Or you could take the automatic error out of the input div and put it
> > on its own where you have more control:
>
> > <?php echo $form->input('field', array('error' => false));?>
> > <div class="error-message'><?php echo $form->error('field', array
> > ('class' => 'nested-div'));?></div>
>
> > -Corie
>
> > On Feb 28, 11:15 pm, horatio <bnab...@says.mu> wrote:
> >> two questions--
>
> >> the default class returned from error() within the html helper is
> >> error-message. how do i override this in my controller?
>
> >> more importantly, how can i inject some html content inside the error div
> >> after a failed form validation?
>
> >> right now its:
>
> >> <div class="error-message">error message here</div>
>
> >> i would like it to hypothetically be:
>
> >> <div class="error-message"><div class="nested-div">error message
> >> here</div></div>
>
> >> is this possible sanely?
>
> >> --
> >> View this message in
> >> context:http://www.nabble.com/customizing-error-messages-from-form-helper-tp2...
> >> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> View this message in context:http://www.nabble.com/customizing-error-messages-from-form-helper-tp2...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
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: