Multiple setDisplayField method

Hello guys, I need help
How I can make the setDisplayField method showing multiple fields
this is my ParentModel
$this->setDisplayField([‘father_name’,‘mother_name’]);

it will show the fatherName;motherName,

Could we add a separator between that 2 field names?
thankyou

Use virutal fields for what you need. Create a virtual field named full_name which returns the value you need. Then in your find('list') call set the valueField option to full_name.

1 Like

Thank you so much it works
protected function _getParentName()
{
return $this->father_name . ’ - ’ . $this->mother_name;
}