Thursday, December 2, 2010

RE: Validation based on another field

Yes, not to display it on the profile when I say "hide it". I will just go
with collecting it, then they can decide to hide it. Much easier that way
and makes more sense.

Thanks,

DAve

-----Original Message-----
From: cricket [mailto:zijn.digital@gmail.com]
Sent: December-03-10 12:50 AM
To: cake-php@googlegroups.com
Subject: Re: Validation based on another field

On Thu, Dec 2, 2010 at 3:05 PM, Dave Maharaj <me@davemaharaj.com> wrote:
> I have a problem I cant seem to get.
>
>
>
> User has Location information (city, state, country) with the option to
> select "Hide my location".
>
>
>
> So if hide location is selected ( $data['private'] => true ) then there is
> no need to enter City, State Country) I hide those fields with jquery on
> selecting the checkbox.
>
>
>
> But if not selected then they must be filled out.
>
>
>
> So how can I force / remove validation for those fields based on what the
> user has selected?

By "Hide my location" do you mean, "Don't display this publicly"? I do
the same thing, and also for email address, telephone, etc. but I
still collect the info (maybe not all fields in all cases). If the
field isn't mandatory, then just set required to false.

In any case, you can always check $this->data[$this->alias]['field']
as the data is already set on the model when validation occurs.

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: