Monday, April 4, 2011

Re: Form error messages

In case anyone else finds this useful here's an article I found which
solves the problem for me

On Apr 4, 3:39 pm, MeatSandwich <i...@babyclothingcentral.co.uk>
wrote:
> Hi all, I'm new to cakephp and very much enjoying learning all about
> it.
>
> I want to have a page with two forms on it. The first is to sign up a
> new user and the other is just a login form in case the user already
> has an account. I created a views/pages/signup.ctp view and put the
> forms in there.
>
> I also made the signup form submit to an 'add' action in my
> users_controller to do the checking and saving. That had the result of
> throwing up errors since I hadn't created an add view. So I redirected
> at the end of the add action to pages/signup.ctp so that the form
> would appear again. However this meant it didn't show any of my error
> messages when for example the users email field was left empty.
>
> So I then created an add view with my two forms in it (exactly the
> same as my signup.ctp above) which now displays the error messages,
> but unfortunately it displays errors on both of the forms. So when a
> user doesn't enter an email address both the forms appear with the
> error about not having a valid email address.
>
> Obviously there is a better way of doing this but I'm buggered if I
> can find it.
>
> Whats the best was so that I can have these two forms on the one page
> and displaying the appropriate error messages on the appropriate form?
>
> thanks in advance

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

No comments: