We Rock
We Rock

Reputation: 103

Validate the fields belonging to other/imported model

I have a model called user and another model called student.

Neither of them have a relation to each other defined in models but the form for user has to post some of the data to student as well.

I want to validate all the fields related to student.

I did:

$impstudent = ClassRegistry::init('Student');

It gets all the fields but I want to know how to invoke the validate for student model from users_controller.

Upvotes: 0

Views: 89

Answers (1)

floriank
floriank

Reputation: 25698

Simply validate it before saving both models or whatever fits your requirements:

    $Model->set($yourData);
    $Model->validates();

Also see http://api20.cakephp.org/class/model#method-Modelvalidates

Upvotes: 1

Related Questions