Jump to:

3462 Posts in 1065 Topics by 740 members

Data Model Questions

SilverStripe Forums » Data Model Questions » DataObjectDecorator and scaffoldSearchFields

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

Page: 1
Go to End
Author Topic: 1508 Views
  • wildflower1975
    Community Member
    59 Posts

    DataObjectDecorator and scaffoldSearchFields Link to this post

    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?

  • Ingo
    Forum Moderator
    801 Posts

    Re: DataObjectDecorator and scaffoldSearchFields Link to this post

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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.