Go back to what Chris said (in your model - stick the message with the
validation):

var $validates = array('foo' => array('rule' => VALID_NOT_EMPTY,
'message' => 'Foo cannot be empty'));

In your view:
echo $form->error(foo);

If you want a specific error like "The username "abba" is already
registered", that can be handled in the view.


You can't have your CakePHP and eat it too....You only want to update an
error in one place, but you don't want to update in two places. I'm sure
there's a way to fetch the validation and parse the rule while in the view,
but why??? What's the point? Yes, according to MVC pattern, but that's a
guideline dude.

But, that's how I do it....validation and errors in the model. It kinda
makes scene. Then I don't have to specify an error a million other places
that I use the model.
--
Baz L
Web Development 2.0
http://WebDevelopment2.com/

On 10/10/07, stefanb <[EMAIL PROTECTED]> 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.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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