Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with ModelAdmin filters and $searchable_fields #29

Open
HARVS1789UK opened this issue Aug 28, 2018 · 0 comments
Open

Compatibility with ModelAdmin filters and $searchable_fields #29

HARVS1789UK opened this issue Aug 28, 2018 · 0 comments

Comments

@HARVS1789UK
Copy link

@sheadawson thanks for the great module, I am finding it pretty easy to get along with and am using it within a number of GridField_ItemEditForms successfully.

I am also trying to make use of it as a filter field to search through results in the list of a GridField using the searchableFields() method (defined on DataObject) on a class of my own (a sub-class of DataObject). For example:

    public function searchableFields() {
        $callback = function($value) {
            return DataObject::get($value)->map('ID', 'getTitle');
        };
        $sourceClassField = DropdownField::create('SourceClass')
            ->setTitle('Source Object Type')
            ->setSource(static::$enabled_classes);
        $sourceIdField = DependentDropdownField::create(
            'SourceID',
            'Source Object Instance',
            $callback
        )->setDepends($sourceClassField);

       return array(
            'SourceClass' => array(
                'filter'    => 'ExactMatchFilter',
                'field'     => $sourceClassField,
                'title'     => 'Source Object Type'
            ),
            'SourceID' => array(
                'filter'    => 'ExactMatchFilter',
                'field'     => $sourceIdField,
                'title'     => 'Source Object Instance'
            )
        );
    }

This makes a request to:

http://jbba.joeharvey.local:8080/admin/payments/CreditTransaction/field/q[DestinationID]/load?val=Fixture which returns a HTTP 404 Not Found and the response Action 'field' isn't available on class PaymentAdmin..

This suggests to me that the field type/module isn't supported in the context of ModelAdmin search fields, is that right or am I doing something wrong?

If that is accurate, would this be functionality you'd be willing to add?

Thanks in advance,

HARVS1789UK

@HARVS1789UK HARVS1789UK changed the title Compatibility with ModelAdmin filters and $searchable_fields Compatibility with ModelAdmin filters and $searchable_fields Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant