Why not just create a second validation method and narrow the first
one to whatever concerns the message you've set for it?

On Fri, Mar 7, 2008 at 6:46 PM, Mike <[EMAIL PROTECTED]> wrote:
>
>  Thanks for the reply!  One of the big reasons I went with Cake is that
>  it seemed to have an active, friendly community.  I'm glad to be part
>  of it! :)
>
>
>
>  I tried this out, and it doesn't seem to work.  Looking at the code in
>  cake/libs/model/model.php, specifically the invalidFields method, just
>  below where the call_user_func_array function is called, it appears
>  that if the user-defined validation method (i.e., my method) returns
>  false, then the Cake code will call Model::invalidate using the
>  default error message for that rule.
>
>  Since this happens after my method has finished executing, this means
>  that the error message that my method set is now overwritten with the
>  default 'message'.
>
>  As a matter of fact - looking at the code in the invalidFields, it
>  looks like it's impossible to have a validation method create a
>  dynamic error message, given the code that's there, now.
>
>  Does anybody else have an interest in being able to create dynamic
>  error messages from within a validation method/function?  If so, how
>  do we ask for this feature to be incorporated into Cake?
>
>  Thanks!
>  --Mike
>
>
>  On Mar 7, 7:31 am, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote:
>  > Have you tried Model::invalidate(...)?
>  >
>  > http://api.cakephp.org/1.2/class_model.html#81c94997c2d6158c40efd9c70...
>
> >
>  > On Mar 6, 10:29 pm, Mike <[EMAIL PROTECTED]> wrote:
>  >
>  >
>  >
>  > > Hello!
>  >
>  > > In CakePHP 1.2, one can define a validation rule (in a model) that
>  > > calls a method to do the validation.  If the method returns false,
>  > > then whatever message was specified for that rule is displayed in the
>  > > view, which is great for most of data validation needs.
>  >
>  > > However, in the case that the method returns false, I'd to have that
>  > > method change the 'message' to be something new (which the method just
>  > > generated).  It looks like I can do this by hacking the cake/  file,
>  > > and by tweaking some code in the invalidFields method (right around
>  > > the calls to call_user_func_array).
>  >
>  > > Is it possible to do this (to have the validation method set/change
>  > > the message dynamically) without hacking Cake itself?  I'm really
>  > > sorry if I've missed this, but I've looked around, but haven't found
>  > > anything that seems directly applicable.
>  >
>  > > Thanks!
>  > > ---Mike- Hide quoted text -
>  >
>  > - Show quoted text -
>
>
>
>  >
>

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