I have 3 tables students, student_races, and races they are joined in a HABTM relation using two models (Student and Race).
I'm trying to use $this->Student->invalidate('StudentRaces'); to invalidate a HABTM input field when no items have been related. After looking at the Cake manual and source code for awhile I've come to the conclusion that this may not be possible. The problem is that the function HTML::setFormTag() requires a model and the field must be specified as 'StudentRaces/StudentRaces' in order for it to save correctly. There is no model named 'StudentRaces' and no field named 'StudentRaces' in the Student model.
If this is possible I really think it would be good to give an example of how to do this in the manual since it isn't obvious how to do this. If it isn't possible this seems like a BIG oversight and I'm wondering if anyone has made a work around that will cause the form field to work correctly which they would be willing to share.
By krowe on 18/7/08
1 - HABTM Validation (Is it possible?)
I have 3 tables students, student_races, and races they are joined in a HABTM relation using two models (Student and Race).
I'm trying to use $this->Student->invalidate('StudentRaces'); to invalidate a HABTM input field when no items have been related. After looking at the Cake manual and source code for awhile I've come to the conclusion that this may not be possible. The problem is that the function HTML::setFormTag() requires a model and the field must be specified as 'StudentRaces/StudentRaces' in order for it to save correctly. There is no model named 'StudentRaces' and no field named 'StudentRaces' in the Student model.
If this is possible I really think it would be good to give an example of how to do this in the manual since it isn't obvious how to do this. If it isn't possible this seems like a BIG oversight and I'm wondering if anyone has made a work around that will cause the form field to work correctly which they would be willing to share.
TIA