Reputation: 103
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
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