Search for translated values in a backend list
3
By default, contents of RainLab.Translate
are not regarded when a search is started in a backend list. Add the following listExtendRecords
method to your Controller to also search for certain translated fields (in this case the name
field in a fr
locale).
public function listExtendRecords($records)
{
$searchTerm = $this->widget->listToolbarSearch->getActiveTerm();
if (strlen($searchTerm)) {
$records = $records->merge(YourModel::transWhere('name', $searchTerm, 'fr')->get());
}
return $records;
}
Be aware that this trick does not return paginated results.
Credits to andreas on Slack.
There are no comments yet
Be the first one to comment