galilee
galilee

Reputation: 461

Silverstripe Gridfield filters not working

I have a site which I've just updated from 2.4 -> 3.1.

On my local environment everything works fine, but once uploaded to production the search filters on GridFields do not work. No errors that I can see, they just don't filter anything.

Has anyone come across this?

class Product extends DataObject {

    static $db = array (
        'URLSegment'=>'Varchar(255)',
        'Name' => 'Text',
        'ProductCode' => 'Text',
        'Description' => 'Text'
    );

    static $has_one = array (
        'ProductPage' => 'ProductPage',
        'OverrideProductImage' => 'Image'
    );

    static $searchable_fields = array( 
        'Name',
        'Description', 
        'ProductCode' 
    );

    static $create_table_options = array(
        'MySQLDatabase' => 'ENGINE=MyISAM'
    );


    public function getCMSFields() {
        return new FieldList(
            new TextField('Name'),
            new TextField('ProductCode'),
            new TextareaField("Description","Description"),
            new Uploadfield("OverrideProductImage", "Product Image")

        );
    }
}

and

class ProductPage extends Page {

    public static $db = array(
        'ShowOnHome' => 'Boolean'
    );

    static $has_many = array (
        'Products' => 'Product'
    );

    public function getCMSFields() {
        $f = parent::getCMSFields();

        $config = GridFieldConfig_RecordEditor::create();
        $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
            'Thumbnail' => 'Product Image',
            'Name' => 'Name',
            'ProductCode' => 'ProductCode', 
            'Description' => 'Description'
        ));

        $config->addComponent(new GridFieldOrderableRows());

        $productsField = new GridField(
            'Products', // Field name
            'Product', // Field title
            $this->Products(), 
            $config
        );

        $f->addFieldToTab('Root.Products', $productsField);

        return $f;
    }
}

Upvotes: 1

Views: 797

Answers (1)

wmk
wmk

Reputation: 4626

Do you have suhosin enabled on your live server? I stumbled over this problem last week, it will be fixed in 3.1.11 which is just around the corner. Maybe checkout the pre release you can download here (including composer command)

Suhosin unfortunately logs to syslog on my debian box, so I didn't find any errors first.

Had to update suhosin.get.max_name_length to get excel export working and suhosin.post.max_name_length to get pagination and column sorting / filtering working.

See Github issue

Upvotes: 2

Related Questions