Again, your controller should be agnostic towards the data. The fields, their
validation and the associated messages displaying the errors should NOT be
in your controller.

You can muck about with validation at the controller level but really it
isn't the elegant or clearly separated approach.




Dani-22 wrote:
> 
> 
> In your controller you can do the following
> 
> if(! $this->Model->save($whatever) )
>    $this->set('$errors', $this->Model->validationErrors);
> 
> That's an array with all validation errors in it, then in your view
> you can do whatever you need with the error messages.
> Hope this helps
> 
> Dani Chilean
> 
> On Oct 10, 3:48 am, stefanb <[EMAIL PROTECTED]> wrote:
>> So you're saying I should put HTML and javascript code in my model
>> too. All I need in my view is a variable sent from the model
>> containing the display code, and echo that out...
>>
>> On Oct 10, 1:58 am, abba bryant <[EMAIL PROTECTED]> wrote:
>>
>> > That isn't accurate either.
>> > The model can set any data it wants. The controller should then forward
>> that
>> > data onto the view. There is no definitive right or wrong way to
>> generate
>> > the error messages - simply a correct layer for displaying them.
>>
>> > If the error pertains to the data the model is supposed to recieve or
>> is
>> > related to a problem fetching data that should be available then by all
>> > means allow the model to store the error messages. Just don't output
>> them
>> > from anything that isn't a view file.
>>
>> > Wayne Fay wrote:
>>
>> > >> > Yes, but according to the MVC pattern, what the user sees (like
>> error
>> > >> > messages) really is supposed to go into the view, not the model...
>>
>> > >> Are you saying that a model cannot generate error messages that need
>> > >> to be displayed in a view?
>>
>> > > You *can*... But according to MVC principles, you *shouldn't*.
>>
>> > > Wayne
>>
>> > --
>> > View this message in
>> context:http://www.nabble.com/Validation-rules-and-error-messages-tf4581362.h...
>> > Sent from the CakePHP mailing list archive at Nabble.com.
> 
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Validation-rules-and-error-messages-tf4581362.html#a13142178
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to