setting displayField to a custom field

4 messages Options
Embed this post
Permalink
David Roda

setting displayField to a custom field

Reply Threaded More More options
Print post
Permalink

Hi fellow CakePHP enthusiasts.

I have a problem which I'm sure is probably pretty simple but I am not
sure how to do it.

I have a standard Users table with first name, last name, etc.

What I would like to do is set the displayField of the Users model to
a concatenation of first_name . " " . last_name

Now I am thinking that I can accomplish this by creating a custom
field in my model which concatenates these two fields, and set the
displayField to this, but I am not sure how to go about creating the
custom field.

Thanks in advance for any help!  I really appreciate it.

David Roda
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

euromark (munich)

Re: setting displayField to a custom field

Reply Threaded More More options
Print post
Permalink

there are behaviours for that (multiple_display_field)
or you do it manually by using "beforeFind()" in your model


On 5 Nov., 23:22, Dave <[hidden email]> wrote:

> Hi fellow CakePHP enthusiasts.
>
> I have a problem which I'm sure is probably pretty simple but I am not
> sure how to do it.
>
> I have a standard Users table with first name, last name, etc.
>
> What I would like to do is set the displayField of the Users model to
> a concatenation of first_name . " " . last_name
>
> Now I am thinking that I can accomplish this by creating a custom
> field in my model which concatenates these two fields, and set the
> displayField to this, but I am not sure how to go about creating the
> custom field.
>
> Thanks in advance for any help!  I really appreciate it.
>
> David Roda
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

David Roda

Re: setting displayField to a custom field

Reply Threaded More More options
Print post
Permalink
Thanks euromark.

what type of logic would I be performing in beforeFind() to accomplish this goal?


On Fri, Nov 6, 2009 at 6:01 AM, euromark (munich) <[hidden email]> wrote:

there are behaviours for that (multiple_display_field)
or you do it manually by using "beforeFind()" in your model


On 5 Nov., 23:22, Dave <[hidden email]> wrote:
> Hi fellow CakePHP enthusiasts.
>
> I have a problem which I'm sure is probably pretty simple but I am not
> sure how to do it.
>
> I have a standard Users table with first name, last name, etc.
>
> What I would like to do is set the displayField of the Users model to
> a concatenation of first_name . " " . last_name
>
> Now I am thinking that I can accomplish this by creating a custom
> field in my model which concatenates these two fields, and set the
> displayField to this, but I am not sure how to go about creating the
> custom field.
>
> Thanks in advance for any help!  I really appreciate it.
>
> David Roda



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Grzegorz Pawlik

Re: setting displayField to a custom field

Reply Threaded More More options
Print post
Permalink

Shouldn't be in afterFind? When data grabbed from DB, You iterate
throug them and add do sth like this
$this->data[$n]['User']['whole_name'] = $this->data[$n]['User']
['name'] . " " . $this->data[$n]['User']['last_name'];

right?


On Nov 6, 7:12 pm, David Roda <[hidden email]> wrote:

> Thanks euromark.
>
> what type of logic would I be performing in beforeFind() to accomplish this
> goal?
>
> On Fri, Nov 6, 2009 at 6:01 AM, euromark (munich) <
>
> [hidden email]> wrote:
>
> > there are behaviours for that (multiple_display_field)
> > or you do it manually by using "beforeFind()" in your model
>
> > On 5 Nov., 23:22, Dave <[hidden email]> wrote:
> > > Hi fellow CakePHP enthusiasts.
>
> > > I have a problem which I'm sure is probably pretty simple but I am not
> > > sure how to do it.
>
> > > I have a standard Users table with first name, last name, etc.
>
> > > What I would like to do is set the displayField of the Users model to
> > > a concatenation of first_name . " " . last_name
>
> > > Now I am thinking that I can accomplish this by creating a custom
> > > field in my model which concatenates these two fields, and set the
> > > displayField to this, but I am not sure how to go about creating the
> > > custom field.
>
> > > Thanks in advance for any help!  I really appreciate it.
>
> > > David Roda
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---