-
Notifications
You must be signed in to change notification settings - Fork 823
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
GridFieldFilterHeader and ArrayLists #10654
Comments
@GuySartorelli is this still relevant with your recent work to make GridField work with ArrayList? |
Dont think so, but I'd have to follow the reproduction steps to be sure. |
This is mostly handled now - though the core complaint that an exception isn't thrown until someone tries to search is still a problem. The exception it throws is better now, but it still isn't thrown until someone searches, so developers could miss the fact that their config is set incorrectly. New reproduction stepsSet up an public function getCMSFields()
{
$fields = parent::getCMSFields();
$list = ArrayList::create([ArrayData::create(['Title' => 'value1']),ArrayData::create(['Title' => 'value2'])]);
$config = GridFieldConfig_Base::create();
$fields->addFieldToTab('Root.Main', GridField::create('test', 'test', $list, $config));
return $fields;
} Accessing the form that owns this
Call $config->getComponentByType(GridFieldDataColumns::class)->setDisplayFields(['Title' => 'Title']); You can now access the form fine, but as soon as you try to search you get this exception:
Add the search context as per the exception (the new $searchContext = BasicSearchContext::create(ArrayData::class);
$searchContext->setFields(FieldList::create([
HiddenField::create(BasicSearchContext::config()->get('general_search_field_name')),
TextField::create('Title', 'Title'),
]));
$config->getComponentByType(GridFieldFilterHeader::class)->setSearchContext($searchContext); Searching now works without exceptions. |
@maxime-rainville Probably still worth looking at throwing that second exception when the form loads instead of waiting for someone to search. |
Affected Version
4.*
Description
GridFieldFilterHeader parameters are typed against SS_List, but since it's using a SearchContext under the hood, it only works with a DataList
This means you don't get the issue until someone actually tries it (for example, I only realized the issue today in an app that's been in production for two years :-) )
I'm not sure what's the best course of action here:
Steps to Reproduce
The text was updated successfully, but these errors were encountered: