I have two tables 1- Users, 2- Groups. Each group has a code that a student can enter in, to join the Group.
On the signup form, I have Group Code field along with other User model fields like username, password etc.
This Group Code field is not a part of Users model. Instead, it is an attribute of Groups model.
Now, my question is when student submits the SignUp form, how it is possible to validate that "Group Code" field??
We can use "onAfterValidate()" method to put logic to validate the Group Code entered by user but in this case, how can I return error to Group Code field on the signup form??
Ahh then why you dont define a custom attribute in your model class like public $group_code; and overwrite this value according to your requirements when you save the form.In this way you can easily ass a custom validation rule and also save the data.