Fix: FilterSelect implicit validation breaks form on hidden column (#1281)#1282
Open
radimvaculik wants to merge 1 commit intomasterfrom
Open
Fix: FilterSelect implicit validation breaks form on hidden column (#1281)#1282radimvaculik wants to merge 1 commit intomasterfrom
radimvaculik wants to merge 1 commit intomasterfrom
Conversation
…1281) Nette's SelectBox constructor adds an implicit "Filled" validation rule when no prompt is set. For a FilterSelect on a column that's hidden (setDefaultHide / handleHideColumn), the input isn't rendered and no value is submitted — the rule fails, the filter container becomes invalid, and Container::getValues() in Datagrid::filterSucceeded() triggers an E_USER_WARNING. Filters are search inputs, not required data entry, so reset the rules on the underlying SelectBox. Added a regression test that validates the filter container with no value submitted and asserts it stays valid.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1282 +/- ##
==========================================
+ Coverage 46.79% 47.54% +0.75%
==========================================
Files 53 53
Lines 2729 2730 +1
==========================================
+ Hits 1277 1298 +21
+ Misses 1452 1432 -20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
I can confirm that the fix works in my project. Thank you! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1281.
Nette\Forms\Controls\SelectBoxconstructor adds an implicitFilledvalidation rule when no prompt is set. For aFilterSelecton a column that's hidden viasetDefaultHide()orhandleHideColumn, the input isn't rendered, so nothing is submitted for it. The rule then fails, the filter container becomes invalid, andContainer::getValues()inDatagrid::filterSucceeded()triggers:Filters are search inputs, not required data entry, so this PR resets the rules on the underlying
SelectBoxinFilterSelect::addControl(). The fix is inherited byFilterMultiSelect(no-op there sinceaddMultiSelectdoesn't add implicit validation).Test plan
testFilterSelectHasNoImplicitValidationintests/Cases/FilterTest.phpt— verified it fails before the fix and passes after.make tests— 29 passed, 1 skipped (MySQL not running).make phpstan— clean.make cs— clean.@jaroslavlibal could you give this branch a try in your project and confirm the warning is gone? 🙏