Re: Use of Multiple Fields in $displayField var in Models
As an example for multiple displayField, this is how I change (e.g. translate) my displayField for my Gender dropdowns. http://github.com/ionas/sna/blob/master/www/app/app_model.php#L12 http://github.com/ionas/sna/blob/master/www/app/models/gender.php#L10 Skip the translation part by removing the inner conditions and foreach loop in the app_models find overwrite In the Gender Model one could easily add {n}.Gender.id to show id next to name. var $displayField = array('%s %s', '{n}.Gender.id', '{n}.Gender.label'); Works I think On Dec 8, 5:52 pm, Marco wrote: > Yes, it is what Marcelo already mentioned. > > On Dec 8, 10:56 am, Dave wrote: > > > I asked about this a while ago and I know there is a multiple displayField > > behavior in the bakery > > > On Mon, Dec 7, 2009 at 8:12 PM, Marcelo Andrade wrote: > > > On Mon, Dec 7, 2009 at 2:44 AM, Mohammad Raheel > > > wrote: > > > > I want to use 2 Concatenated fields in $displayField variable in a > > > > model so that the view can show both FirstName and LastName in the > > > > dropdown selection. > > > > > var $displayField = "firstName"; > > > > > I need something like > > > > var $displayField = "firstName"." "."lastName"; > > > > This is not the correct syntax. About using more > > > than one field in displayField, I've found this old > > > ticket[1] and this article at bakery[2]. > > > > But, as Marco said, Set::combine is so powerfull. > > > Maybe you should give it a try. > > > > [1]https://trac.cakephp.org/ticket/644 > > > [2]http://bakery.cakephp.org/articles/view/multiple-display-field-3 > > > > Atenciosamente. > > > > -- > > > MARCELO DE F. ANDRADE > > > Belem, PA, Amazonia, Brazil > > > Linux User #221105 > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > > > with their CakePHP related questions. > > > > You received this message because you are subscribed to the Google Groups > > > "CakePHP" group. > > > To post to this group, send email to cake-php@googlegroups.com > > > To unsubscribe from this group, send email to > > > cake-php+unsubscr...@googlegroups.com > > om>For more options, visit this group at > > >http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Use of Multiple Fields in $displayField var in Models
Yes, it is what Marcelo already mentioned. On Dec 8, 10:56 am, Dave wrote: > I asked about this a while ago and I know there is a multiple displayField > behavior in the bakery > > > > On Mon, Dec 7, 2009 at 8:12 PM, Marcelo Andrade wrote: > > On Mon, Dec 7, 2009 at 2:44 AM, Mohammad Raheel > > wrote: > > > I want to use 2 Concatenated fields in $displayField variable in a > > > model so that the view can show both FirstName and LastName in the > > > dropdown selection. > > > > var $displayField = "firstName"; > > > > I need something like > > > var $displayField = "firstName"." "."lastName"; > > > This is not the correct syntax. About using more > > than one field in displayField, I've found this old > > ticket[1] and this article at bakery[2]. > > > But, as Marco said, Set::combine is so powerfull. > > Maybe you should give it a try. > > > [1]https://trac.cakephp.org/ticket/644 > > [2]http://bakery.cakephp.org/articles/view/multiple-display-field-3 > > > Atenciosamente. > > > -- > > MARCELO DE F. ANDRADE > > Belem, PA, Amazonia, Brazil > > Linux User #221105 > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com > om>For more options, visit this group at > >http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Use of Multiple Fields in $displayField var in Models
I asked about this a while ago and I know there is a multiple displayField behavior in the bakery On Mon, Dec 7, 2009 at 8:12 PM, Marcelo Andrade wrote: > On Mon, Dec 7, 2009 at 2:44 AM, Mohammad Raheel > wrote: > > I want to use 2 Concatenated fields in $displayField variable in a > > model so that the view can show both FirstName and LastName in the > > dropdown selection. > > > > var $displayField = "firstName"; > > > > I need something like > > var $displayField = "firstName"." "."lastName"; > > This is not the correct syntax. About using more > than one field in displayField, I've found this old > ticket[1] and this article at bakery[2]. > > But, as Marco said, Set::combine is so powerfull. > Maybe you should give it a try. > > [1] https://trac.cakephp.org/ticket/644 > [2] http://bakery.cakephp.org/articles/view/multiple-display-field-3 > > Atenciosamente. > > -- > MARCELO DE F. ANDRADE > Belem, PA, Amazonia, Brazil > Linux User #221105 > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Use of Multiple Fields in $displayField var in Models
On Mon, Dec 7, 2009 at 2:44 AM, Mohammad Raheel wrote: > I want to use 2 Concatenated fields in $displayField variable in a > model so that the view can show both FirstName and LastName in the > dropdown selection. > > var $displayField = "firstName"; > > I need something like > var $displayField = "firstName"." "."lastName"; This is not the correct syntax. About using more than one field in displayField, I've found this old ticket[1] and this article at bakery[2]. But, as Marco said, Set::combine is so powerfull. Maybe you should give it a try. [1] https://trac.cakephp.org/ticket/644 [2] http://bakery.cakephp.org/articles/view/multiple-display-field-3 Atenciosamente. -- MARCELO DE F. ANDRADE Belem, PA, Amazonia, Brazil Linux User #221105 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Use of Multiple Fields in $displayField var in Models
I think you can't do it. One solution: controller: $this->User->recursive = -1; $users= $this->User->find('all', array('fields'=>array('User.id', 'User.FirstName', 'User.LastName'))); $users = Set::combine($users, '{n}.User.id', array('%s %s', '{n}.User.LastName', '{n}.User.FirstName')); $this->set('users', $users') view: echo $form->input('id', array('options'=>$users)); Marco On Dec 7, 3:44 am, Mohammad Raheel wrote: > I want to use 2 Concatenated fields in $displayField variable in a > model so that the view can show both FirstName and LastName in the > dropdown selection. > > var $displayField = "firstName"; > > I need something like > var $displayField = "firstName"." "."lastName"; > > The above statement is not valid in a variable declaration inside a > class. > > Please advice. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Use of Multiple Fields in $displayField var in Models
I want to use 2 Concatenated fields in $displayField variable in a model so that the view can show both FirstName and LastName in the dropdown selection. var $displayField = "firstName"; I need something like var $displayField = "firstName"." "."lastName"; The above statement is not valid in a variable declaration inside a class. Please advice. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
MultipleDisplayFields Behavior - possible solution to handling multiple fields in $displayField
Not claiming any beauty, efficiency or adequate testing here... : http://bin.cakephp.org/view/1976615209 This includes henthoca's beforeFind check as well. @see http://groups.google.com/group/cake-php/browse_thread/thread/d4aa1929ce4d61c7/edcacb9354ff1f7a I've assumed a default of "{first_name} {last_name}" With this you can do something like: var $displayField = 'full_name'; var $actsAs= array('MultipleDisplayFields'); or var $displayField = 'full_name'; var $actsAs = array('MultipleDisplayFields' => array('pattern' => '%s, %s', 'fields' => array('lname', 'fname') ) ); Unfortunately behaviors aren't invoked for non-primary models (not yet sure if this is by design or not) so to get this to work you have to place this in AppModel: function afterFind($results, $primary = false) { if (!$primary) { foreach($this->behaviors as $behaviorClass => $behavior) { if (method_exists($behavior, 'afterFind')) { $results = $behavior->afterFind(&$this, $results, $primary); } } } return $results; } (in the bin paste as well) Not very clean but as far as I can tell it's what you have to do (aside from putting all the logic in AppModel or in your model directly). Comments encouraged. -- Travis --~--~-~--~~~---~--~~ 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: multiple fields in $displayField.
On May 24, 12:31 am, Ruud Gâst <[EMAIL PROTECTED]> wrote: > Hello there, > > I've been trying to fill a SELECT-tag by using the generateList > function, this works great! Although I want to fill it with multiple > fields from the table, eg. firstname . ' ' . lastname. How can I pull > this off? > > Greets Ruud http://groups.google.com/group/cake-php/search?group=cake-php&q=generateList+multiple+field --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
multiple fields in $displayField.
Hello there, I've been trying to fill a SELECT-tag by using the generateList function, this works great! Although I want to fill it with multiple fields from the table, eg. firstname . ' ' . lastname. How can I pull this off? Greets Ruud --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---