Relation Required Fields

This is the table structure I am using. ( The issue I am having is that I am unable to require only home phone, instead due to the way it is setup, it requires all phone fields if I put ‘phone’ in my rules. How would I get it to only require ‘home’ or any other specific phone fields I want to require?

Most relations issue should be able to solve in

So you can add "condition"=>"phone_field_id=1" in relations array to return all home phone.

Good Luck.

Hi blupointmedia.

The rules apply to model’s attributes only by the model’s validate() method usually called by save(). In fact, how can one check a rule on the related table when there are not yet records in both tables?

You can try different approuch. Foe example, if you provide a composite form containing person’s data together with telephone numbers, your controller can check the presence (or absence) of home telephone number.