create a helper for you form error logic lets call it ErrorsHelper http://book.cakephp.org/view/98/Helpers
you can move all you logic in the helper and call it like so: echo $errors->getErrors($this->ModelName->invalidFields()) you might have to play with it but helpers are the mothod of choice for moving bulky logic out of the view On Jul 28, 10:39 am, Shaun <[email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
