Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #2794 Add support for unmapped filter fields (yceruto)
This PR was merged into the 2.0.x-dev branch. Discussion ---------- Add support for unmapped filter fields The current exception is good for DX (typos via the YAML config), but we often need to create a filter that is not directly related to any mapped property. Now users can achieve this by creating a custom Controller and overriding the `createFiltersForm ()` method, but this proposal also makes it possible through the YAML configuration: ```yaml easy_admin: entities: Category: # ... list: filters: [{ property: 'country', type: 'App\Form\Filter\CountryFilterType', mapped: false }] ``` the new option `mapped` allow you to skip this EasyAdmin validation. Closes #2793 Commits ------- d9d82d6 Add support for unmapped filter fields
- Loading branch information
Showing
4 changed files
with
52 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/Configuration/fixtures/exceptions/filters_unmapped_without_type.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# TEST | ||
# items in the 'filters' option must define the 'type' option when they are unmapped | ||
|
||
# EXCEPTION | ||
expected_exception: | ||
class: \InvalidArgumentException | ||
message_string: 'The "foo" filter defined in the "list" view of the "Category" entity must define its own "type" explicitly because EasyAdmin cannot autoconfigure it.' | ||
|
||
# CONFIGURATION | ||
easy_admin: | ||
entities: | ||
Category: | ||
class: AppTestBundle\Entity\UnitTests\Category | ||
list: | ||
filters: [{ property: 'foo', mapped: false }] |