This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

pilotus111055
pilotus111055

Hi, I defined item with hasMany which gives me dropdown with all users. But the dropdown display only. e.g. surname: as per this definition ->

nameFrom: surname

What I need is to display list of full names.

Can you please advise how to get name + surname into the dropdown?

Thank you.

noideawhattotypehere
noideawhattotypehere

In your model: public function afterFetch() { $this->full_name = $this->name . ' ' . $this->surname; }

then in config: nameFrom: full_name

ademin
ademin

Doesn't work for me

alxy
alxy

Use an accessor. Note, that these fields cannot be searched or sorted.

kjell190633592
kjell190633592

Use accessor. But remember that these fields cannot be searched or sorted.

public function getFullNameAttribute()
{
return $this->first_name . " " . $this->last_name;
}

Call the function with this call: nameFrom: full_name

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.