silverstripe-dependentdropdownfield
silverstripe-dependentdropdownfield copied to clipboard
Compatibility with ModelAdmin filters and $searchable_fields
@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_ItemEditForm
s 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