Do you want to add this to a specific admin, or to any admin that the dataobject you’re interested in happens to be displayed in?
If it’s for a specific admin, if that admin is a subclass of ModelAdmin
the easiest way is probably to create an extension which implements updateSearchForm()
.
If you want to apply this to the search form of an admin the dataobject is displayed in, you can implement scaffoldSearchFields()
directly in the class (don’t forget to call $fields = parent::scaffoldSearchFields();
in that method). Something like this:
public function scaffoldSearchFields($_params = null)
{
$fields = parent::scaffoldSearchFields($_params);
$fields->replace('Name', DropdownField::create('Name')->setSource(static::get()->map('Name', 'Name')));
return $fields;
}
If it’s a dataobject you don’t have control over (e.g. from some module)… well, comment back if that’s the case and I’ll see what options you have, but it’ll get pretty hairy for that situation. There’s no extension point in scaffoldSearchFields()
at the moment.