21282 Posts in 5730 Topics by 2601 members
| Go to End | ||
| Author | Topic: | 1187 Views |
-
Re: SS3 - how to set searchable fields for a dataobject

27 July 2012 at 1:59am
many thanks!
ModelAdmin automatically creates the Contact GridField for the LeadsAdmin. Your codes overwrite that gridfield.
I think it is a 'bug' that GridFieldAutocompleter doesn't look into the $searchable_fields of the Contact object to find out what searchable_fields are. It only checks if the Contact object has a 'Name' field or not to decide whether the Contact object is searchable or not.
Although your solution works but i think the perfect solution is to update The GridFieldAutoCompleter. Hope the SS team can look into this?
regards,
Ben -
Re: SS3 - how to set searchable fields for a dataobject

27 July 2012 at 2:04am
Yep at the moment it really isn't obvious what went wrong when the "No searchable fields could be found for class ##" error occurs.
-
Re: SS3 - how to set searchable fields for a dataobject

15 February 2013 at 6:05am Last edited: 15 February 2013 6:06am
I stumbled over the same bug but after some trial and error I decided to modify the GridFieldAutocompleter in the core. For anyone interested:
framework/forms/gridfield/GridFieldAddExistingAutocompleter.php line 260Old code:
protected function scaffoldSearchFields($dataClass) {
$obj = singleton($dataClass);
if($obj->hasDatabaseField('Title')) {
return array('Title');
} else if($obj->hasDatabaseField('Name')) {
return array('Name');
} else {
return null;
}
}New code:
protected function scaffoldSearchFields($dataClass) {
$obj = singleton($dataClass);
foreach($obj->searchableFields() as $k => $v){
$searchable[] = $k;
}
return $searchable;
}
| 1187 Views | ||
| Go to Top |


