Hello all, This has probably been asked a couple of times allready. I would like to use multiple fields to generate the labels in a drop down list box. I searched the list, and this search came up with several different strategies to achieve this. I tried to implement one of these strategies but ran in to a problem... I hope someone can help me.
I have the following models: Member - id - login - last_name - first_name -member_type_id MemberType - id - title Event - id - description - date Registrations - id - event_id - member_id I made all the models, controllers and views using the cake bake console. That gave me allready a lot of funtionality. It's great fun working with something that does the boring parts for you and allows you to reach the stage in your project where it becomes more interesting so fast. This is my first attempt at something with CakePHP btw, and the main purpose of the application I'm building is to allow me to learn how to use it. But basically it is an event registration system for our club. In the schaffolds that were build the drop down list boxes all jsut displayed numerical IDs. I understood that this was because I didn't use "name" or "title" for the database field that has the most meaningfull description. I solved this by setting $displayField in the model to something usefull. So in the "Member" model I set $displayField initalls to "login". But I would be nice if I could use "first_name last_name" for the lables in the member_id drop down box on my event registration form. I found a possible solution here: http://bakery.cakephp.org/articles/view/multiple-display-field-3 And I decided to use the Set::Combine suggestion made by Barry. So in the Registrations controller I replaced: $members = $this->Registration->Member->find('list'); with: $members = $this->Registration->Member->find('all'); $members = Set::Combine( $members, '{n}.Member.ID', array( '{0}, {1}', '{n}.Member.last_name', '{n}.Member.first_name' ) ); The weird thing is that with this code the drop down list box that gets generate for member_id now, in stead of containing a list of al "login" values, now contained only one value. The last_name + first_name of the (alphabetically) last member in the table. So the result of my Set::Combine seems to be an array with just one item. Now why is that? Hope someon can help me here. Krist -- [email protected] [email protected] Bremgarten b. Bern, Switzerland -- A: It reverses the normal flow of conversation. Q: What's wrong with top-posting? A: Top-posting. Q: What's the biggest scourge on plain text email discussions? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~----------~----~----~----~------~----~------~--~---
