Re: Scaffolding question
You can use the bake.php script for generate scaffolded Models, Views, and Controllers. This generates actual code so you don't have to set the $scaffold variable. You can then remove the select box from the view code and edit the controller to set the customer_id there. Cheers, Sonic --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Scaffolding question 2
Your table structure should be something like: students (id, name), awards_ students (student_id, award_id) awards (id, name, award_type_id), award_types (id, award_name) Your model associations should then be: Student hasAndBelongsToMany Award, Award hasOne AwardType Set the reverse assocations if you need them. HTH, Sonic On 4/17/07, surge [EMAIL PROTECTED] wrote: Another question about scaffolding: Let's say I have table student and two other tables: student_awards, and award_types. Here's an approximate description of each table: student (id, name), student_awards (id, student_id, award_id) award_types (id, award_name) The idea is that a student has many awards and each award is looked up in award_types. If I understand correctly, the student model should include a hasMany association to student_awards and student_awards should include a belongTo association to award_types. OK, I'm using scaffolding for all this and when I do an edit on a student, no controls relating to the awards are shown. Actually, I'm not sure what should be shown in this case. I do see a query that selects all records from student_awards that have the current student id, but like I said, no other controls are shown. Thanks for any suggestions! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Scaffolding question
If you just select the customer you want and save it the student will only be associated to that customer. If you want that customer to be already selected prior to going to the add student page, set the student id in the URL or session and edit the CustomersController::add() action to get the id from the relevant place. cheers, Sonic On 4/17/07, surge [EMAIL PROTECTED] wrote: Hi everybody, Let's say I have table student and customer. A customer can have many students and students are unique to a customer. The scaffolded edit page of a student includes a dropdown of all customers -- I included customer to the belongsTo relationship of the student model -- and I want to limit it only to the customer that the student belongs to. How do you do it in scaffolding? Hope there's a quick solution to this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Scaffolding question
See, because there's a potential for selecting the wrong customer on the student form, that dropdown should really contain only one customer. Or that dropdown shouldn't be shown at all. Or the scaffolding should be taken down. Is there a way to get rid of the other customers in the dropdown without taking down the scaffolding? Thanks for the reply by the way! On 4/17/07, Sonic Baker [EMAIL PROTECTED] wrote: If you just select the customer you want and save it the student will only be associated to that customer. If you want that customer to be already selected prior to going to the add student page, set the student id in the URL or session and edit the CustomersController::add() action to get the id from the relevant place. cheers, Sonic On 4/17/07, surge [EMAIL PROTECTED] wrote: Hi everybody, Let's say I have table student and customer. A customer can have many students and students are unique to a customer. The scaffolded edit page of a student includes a dropdown of all customers -- I included customer to the belongsTo relationship of the student model -- and I want to limit it only to the customer that the student belongs to. How do you do it in scaffolding? Hope there's a quick solution to this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---