I haven't tested it but the model does have access to the data submitted. 

Perhaps something along the lines of ( untested and I might be totally wrong
about the variable's name / key etc ) but...

... 'message' => "The username {$this->data['username']} is already
registered",
...

might do the trick. Don't get too excited until you try it though since I
haven't.


stefanb-3 wrote:
> 
> 
> OK, assuming the validation message is placed in the model, how can I
> then display an error message like this:
> 
> The username "abba" is already registered
> 
> 
> On Oct 10, 8:49 pm, abba bryant <[EMAIL PROTECTED]> wrote:
>> Instead of trolling how about you re-read what I wrote.
>> A message is data - how that message is presented is not. An error
>> message
>> or a string of text is a great deal less than the html / javascript / css
>> used to display that message.
>>
>> Putting data into a model whether it maps to a field in a table or not is
>> the CORRECT implementation of an MVC pattern. Use the view to output said
>> data and to format and mark it up how you would like.
>>
>> Abba
>>
>>
>>
>> stefanb-3 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.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#a13164129
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