Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

DataObjectDecorator and scaffoldSearchFields

Go to End

2 Posts   2197 Views


Community Member, 63 Posts

25 February 2010 at 5:39pm

Has anybody tried to make a Custom Search field on a Member Role Decorator?

I've got a custom MemberRole extends DataObjectDecorator

and the updateForumFields functions all work sweet.

Now I want to have my Suburb field shown as a DropdownField instead of a TextField in a default search.

function extraStatics() {
return array( 'db' => array(
'Suburb' => 'Varchar',
'City' => 'Varchar'),
'searchable_fields' => array( 'FirstName','Surname','Suburb','City' ),

This bit works and shows the Suburb and City fields as text boxes.

I'm getting the "build the Search form" function to call the following function (in the Role Decorator .php ) and it barfs on the

$context = parent::getDefaultSearchContext();

line with [User Error] Uncaught Exception: Object->__call(): the method 'scaffoldsearchfields' does not exist on 'MemberRole'

public function getCustomSearchContext(){

$context = parent::getDefaultSearchContext();
$suburbs = self::get_suburbs();

$suburbMap = array_combine($suburbs, $suburbs);
$suburbMap = null;

$suburbField = new DropDownField( 'Suburb', 'Suburb', $suburbMap);
return $context;

Do i need to rewrite/copy the scaffoldsearchfields function (which sounds wrong) or am I just calling it incorrectly?


Forum Moderator, 801 Posts

25 March 2010 at 10:31pm

Try $context = $this->owner->getDefaultSearchContext(); instead :)