Awesome!! Thank you very much!

(I do understand that this decision was made independent of my
questions about this feature, but I figure that it's a nice feature
that I'm looking forwards to, and so saying 'Thanks' seems to be a
good thing to do :)  )

Thanks!
--Mike

On Mar 8, 6:42 am, nate <[EMAIL PROTECTED]> wrote:
> This will be implemented before the next release.
>
> On Mar 7, 8:26 pm, Mike <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thanks for your suggestion - I was thinking about that, and here's
> > what I came up with.  If you can see any holes/offer any refinements,
> > I'd love to hear about them :)
>
> > Part of the reason I'm against this is that I've already got a
> > function that does what I want, and I'm looking to reuse it in
> > CakePHP, rather than redo everything the Cake way.
>
> > Another part is that I think that if I redo this in Cake, it'll end up
> > being more awkward, because I want this functionality to be used for
> > multiple fields (so I'll need the same collection of rules, for each
> > and every field).
>
> > My goal:
> > I want to create a directory on the server, so that users can upload
> > files to the server.  When the 'superuser' creates the directory, I
> > want there to be 2 options:
> > 1) Use an existing directory
> > 2) Use an existing directory if it's there, and create it if not.
>
> > So, breaking this down into pieces, it seems like there are a couple
> > of steps:
> > 1) If the directory exists:
> > 1.1) If it's writable, then we're done & we're good
> > 1.2) If it's NOT writable, then we're done & we've got an error
>
> > 2) If it doesn't exist:
> > 2.1) If the user has elected to create the directory when it doesn't
> > exist,
> >           then create it
> >    2.1.1) We may encounter errors trying to create the directory
>
> > 2.2) If the user has elected to NOT create the directory when it
> > doesn't exist
> >           then we're done, and we've got an error
>
> > Basically, the user types the directory into a textbox, then checks a
> > checkbox to indicate 'create if not present'
>
> > So - if I have a rule which says 'check for the existence (and
> > writability) of the directory', and it finds that the directory isn't
> > there, then we may need to give the user an error, OR we may not
> > (depending on the 'create if not already there' checkbox).  That would
> > be 1 rule, I guess.
>
> > Next, if the directory doesn't exist, but we want to create it, we'll
> > try to do that.  Which is a second rule.  There are a couple of
> > different things that could go wrong, so I guess we'll use a semi-
> > generic error message, and hope that's helpful enough :)
>
> > This all gets further complicated by a desire to reuse this for
> > several different fields - now I need to copy this set of validation
> > rules into the second (and third, etc, etc) fields, too, which is
> > getting kind of awkward.  It's not the end of the world, but having
> > all the (related) logic in one function is kinda nice, and this way,
> > that one function can produce exact error messages.
>
> > Thanks!
> > --Mike
>
> > On Mar 7, 4:19 pm, "b logica" <[EMAIL PROTECTED]> wrote:
>
> > > 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 -- Hide quoted text -
>
> > > - Show quoted text -- 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