Skip to content

Fix: FilterSelect implicit validation breaks form on hidden column (#1281)#1282

Open
radimvaculik wants to merge 1 commit intomasterfrom
fix/1281-filter-select-hidden-column-validation
Open

Fix: FilterSelect implicit validation breaks form on hidden column (#1281)#1282
radimvaculik wants to merge 1 commit intomasterfrom
fix/1281-filter-select-hidden-column-validation

Conversation

@radimvaculik
Copy link
Copy Markdown
Member

Summary

Fixes #1281.

Nette\Forms\Controls\SelectBox constructor adds an implicit Filled validation rule when no prompt is set. For a FilterSelect on a column that's hidden via setDefaultHide() or handleHideColumn, the input isn't rendered, so nothing is submitted for it. The rule then fails, the filter container becomes invalid, and Container::getValues() in Datagrid::filterSucceeded() triggers:

Nette\Forms\Container::getValues() invoked but the form is not valid (form 'filter').

Filters are search inputs, not required data entry, so this PR resets the rules on the underlying SelectBox in FilterSelect::addControl(). The fix is inherited by FilterMultiSelect (no-op there since addMultiSelect doesn't add implicit validation).

Test plan

  • Added regression test testFilterSelectHasNoImplicitValidation in tests/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? 🙏

…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
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.54%. Comparing base (e5faff0) to head (894e9d0).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaroslavlibal
Copy link
Copy Markdown
Contributor

I can confirm that the fix works in my project. Thank you!

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

Successfully merging this pull request may close these issues.

getValues() on filter container triggers E_USER_WARNING when a FilterSelect column is hidden

2 participants