What if there was a case where you didn't want to save all of the
fields again when you're updating a record?

For instance, if a user is updating his or her User record, and wants
to edit a username and birthdate, for example.  You probably wouldn't
have a form field for 'password' in this same place, so that field
would not be included in your array of data being saved, but even if
password is required, you wouldn't expect this to throw an error.

I haven't done much w/ 1.2 validation, and I don't really know what
the difference is between allowEmpty and required, but in 1.1 if a
field was not present in your array of save data, it was not
validated.  Perhaps 1.2 solves this all by using required to specify a
field has to be present in the array, and allowEmpty to say, if the
field is present, it can't be empty...? I have no idea...

If you wanted to not allow a field to be saved, you can always
unset(this->data[Model][field]) or I believe there's an
'expectedFields' attribute to the save function.

On Apr 29, 2:55 pm, jonknee <[EMAIL PROTECTED]> wrote:
> > well my thinking is, if you wanted a field validated, you would have a
> > form field present for it, at which point it would pass this field
> > along for validation
>
> You should never trust your validation to the form values that should
> be coming in from the user (you should never trust *anything* from the
> user). The user could easily not pass form fields and could also
> easily pass values you don't expect.A model with a field marked as
> required should always be required, no matter the circumstances.
>
> Luckily, it appears CakePHP is doing just that. I just tried removing
> a form field for a model that had a required validation and it
> wouldn't save. I changed required=True to required=False and it saved
> just fine.
>
> I think the problem MarcS is having is simply a problem in his
> validation routine. Can you post some code?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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