In the add/edit action of your model do you know whether you're
dealing with a LeadPassenger or Person? You can dynamically remove the
validation from the controller (you can just use unset() to remove the
rule that isn't required) - does that help at all?

You can also use custom validation methods in the model, you could
have your conditional logic in there:

http://book.cakephp.org/view/152/Adding-your-own-Validation-Methods

Toby

On Mar 12, 12:55 pm, sebp999 <[email protected]> wrote:
> Noob queston sorry but what's the most elegant way to do this?
>
> I have a travel booking system.  A person makes a booking and takes
> other people with him/her.  So
> - LeadPassenger hasMany Booking, and
> - Booking hasAndBelongsToMany Person (person = everybody who goes on
> the trip, not necessary lead passenger)
>
> Both LeadPassenger and Person are model Person.
>
> I want to make sure that I have a postal address for the lead
> passenger but it doesn't make sense to gather addresses for the
> others.
>
> Is there a way of doing that by validating in the usual way ie
> $validate=etc? I can't use the person model to validate because it is
> doing two things. (lead passengers whose address I need and others
> whose address I don't care about). So the question is where is the
> best place to do that validating, and how?
>
> Thanks!

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 [email protected]
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