an error (unlikely, as the form is redisplayed, but whatever) just add
this at the top:
if (!empty($form->validationErrors)) {
and include a notice that there were errors and to check below (where
the errors are displayed with each element). Displaying errors one at
a time would be a huge waste of time for the user.
On Tue, Jul 28, 2009 at 10:39 AM, Shaun<sbefort@gmail.com> wrote:
>
> I prefer to display form validation errors at the top of the form
> rather than under each form field. I would also like to display only
> one error at a time. I have the following code at the top of my form:
>
> <?php
> if ($form->isFieldError('user_username')){
> echo $form->error('user_username');
> } elseif ($form->isFieldError('user_password')) {
> echo $form->error('user_password');
> } elseif ($form->isFieldError('user_given_name')) {
> echo $form->error('user_given_name');
> } elseif ($form->isFieldError('user_surname')) {
> echo $form->error('user_surname');
> } elseif ($form->isFieldError('user_email')) {
> echo $form->error('user_email');
> }
> ?>
>
> How can I move the nested if statements out of my view? Thanks.
> >
>
--~--~---------~--~----~------------~-------~--~----~
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:
Post a Comment