My try-it-out application for Cake is mainly about a HABTM relationship of students to courses, with each course belonging to a schedule slot.
I have a page containing a form which displays each of the records (seven, at present) from the schedule-slot table. Each of these schedule-slot records is associated in the form with an html select. Each schedule-slot's set of options is different, representing the courses which are taught in that schedule slot. A student brings up the page and sees the existing value of each select, representing his/her chosen course for each schedule slot. That is, the student sees his/her schedule. Some of the schedule slots are free periods for the student, so those will display "Please choose a course." Assume that all school days are alike. So the student sees something like the following: 1st Period: English Literature 2 2nd Period: -- Please select a course -- 3rd Period: History of Courtesans of 17th Century France 4th Period: Nutrition 4 5th Period: -- Please select a course -- ... and so forth. Multiple selects are not possible for each schedule slot -- naturally, because the student can only attend one course per schedule slot. The student user chooses courses, then clicks "Save". Of course I then want to write out the linking table records (courses_students) based on the chosen courses for that particular student. The save operation will involve creating zero or more linking table records and deleting zero or more linking table records. No new courses or new students will be created during the save operation. How should I translate the value of the selects into a save() operation? I have read through "Saving hasAndBelongsToMany" in the Models section of the manual (http://manual.cakephp.org/chapter/models), but I'm not sure how that advice applies to this situation. Should I create a custom routine (maybe a subclass of model::save) to do the saving? Or should I try to convert the form output into the data-array format which model::save() already understands? Also, should I invoke model::save once for each schedule-slot, or try to save everything in a single call? I can code this save operation using any of the methods I mentioned above. The difficulty is not that I can't find a way to do it. The difficulty is that I don't know the correct way, the easy way, to handle similar situations in the future. Thank you for any suggestions. Regards, Ralph --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~----------~----~----~----~------~----~------~--~---
