This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
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.
In your model: public function afterFetch() { $this->full_name = $this->name . ' ' . $this->surname; }
then in config: nameFrom: full_name
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