silverstripe-framework: BadMethodCallException when scafolding search

Affected Version

SilverStripe 4.3

Description

Originally reported by @purplespider on SilverStripe forum

[Emergency] Uncaught BadMethodCallException: Object->__call(): the method 'scaffoldSearchField' does not exist on 'PurpleSpider\MSG\SalesCategory'
GET /admin/pages/edit/show/44

Line 54 in /vendor/silverstripe/framework/src/Core/CustomMethods.php
Source

45      * @throws BadMethodCallException
46      */
47     public function __call($method, $arguments)
48     {
49         // If the method cache was cleared by an an Object::add_extension() / Object::remove_extension()
50         // call, then we should rebuild it.
51         $class = static::class;
52         $config = $this->getExtraMethodConfig($method);
53         if (empty($config)) {
54             throw new BadMethodCallException(
55                 "Object->__call(): the method '$method' does not exist on '$class'"
56             );
57         }
58 
59         switch (true) {
60             case isset($config['callback']): {

Trace

    SilverStripe\View\ViewableData->__call(scaffoldSearchField, Array)
    DataObject.php:2234
    SilverStripe\ORM\DataObject->scaffoldSearchFields()
    DataObject.php:2175
    SilverStripe\ORM\DataObject->getDefaultSearchContext()
    GridFieldFilterHeader.php:249
    SilverStripe\Forms\GridField\GridFieldFilterHeader->getSearchContext(SilverStripe\Forms\GridField\GridField)
    GridFieldFilterHeader.php:269
    SilverStripe\Forms\GridField\GridFieldFilterHeader->getSearchFieldSchema(SilverStripe\Forms\GridField\GridField)
    GridFieldFilterHeader.php:491
    SilverStripe\Forms\GridField\GridFieldFilterHeader->getHTMLFragments(SilverStripe\Forms\GridField\GridField)
    GridField.php:434
    SilverStripe\Forms\GridField\GridField->FieldHolder()
    call_user_func_array(Array, Array)
    ViewableData.php:485
    SilverStripe\View\ViewableData->obj(FieldHolder, , 1)
    ViewableData.php:547
    SilverStripe\View\ViewableData->XML_val(FieldHolder, , 1)
    SSViewer_Scope.php:323

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

It should be possible to define a “custom” summary field without also defining $searchable_fields, if that ability has been lost then it’s definitely a regression

Agreed, but I didn’t realise defining $searchable_fields whenever you define $summary_fields was a strict requirement?