Saturday, November 29, 2008

Validation from another model

Hi everyone. I'm really stuck here :)

I have problem with displaying an error next to a form field of the
form that is being validated in another model.

I have two models: Products and Cart. Product_controller has VIEW
action through which I can select product variant from drop down menu
and change quantity of that product that's about to be added. Form
action is Products/addToCart function which saves data into Cart model
and than redirects back to Product::view. Validation of quantity field
works fine in Cart model and I know this because it won't save() if
validation fails. That way I can use setFlash() method to throw a
error message to a user explaining that "some error in validation
occured" but what I want is to make CakePHP show an error message
(from $validate variable) next to my invalid field (quantity) when it
redirects back to Product::view.

Someone please help me because I'll be needing this quite often.

I had similar problem with saving a Comment on a Post but now I ran
into this problem once again and want to solve it, with your help of
course ...

Best regards

Luka
--~--~---------~--~----~------------~-------~--~----~
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: