Skip to content

fix: render validation state on DateTimeControl and ColorPicker - #127

Merged
dakorpar merged 2 commits into
masterfrom
fix/113-datetime-validation-feedback
Aug 14, 2026
Merged

fix: render validation state on DateTimeControl and ColorPicker#127
dakorpar merged 2 commits into
masterfrom
fix/113-datetime-validation-feedback

Conversation

@dakorpar

Copy link
Copy Markdown
Member

Closes #113

Problem

DateTimeControl (backing addDate(), addDateTime(), addTime()) uses StandardValidationTrait, which supplies showValidation() — but the class never declared implements IValidationInput. BootstrapRenderer::renderControl() gates that call on the interface:

if (($this->form->showValidation || $control->hasErrors()) && $control instanceof IValidationInput) {
    $controlHtml = $control->showValidation($controlHtml);
}

so the input never received is-invalid.

The <div class="invalid-feedback"> was in fact emitted all along. Bootstrap styles .invalid-feedback as display: none unless a sibling input carries .is-invalid, which is why the message rendered but stayed invisible — matching the screenshot in the issue.

-<input type="date" name="date" id="frm-date" class="form-control">
+<input type="date" name="date" id="frm-date" class="form-control is-invalid">
   <div class="invalid-feedback">Foobar error message<br></div>

Fix

Added implements IValidationInput to DateTimeControl. ColorPicker had the identical trait/interface mismatch — found by auditing every class in src/Inputs/ — and is fixed the same way. Those two were the only ones; DateInput/DateTimeInput inherit the interface via TextInput.

No renderer changes. No tests/data/ fixtures shifted — none exercise an errored date or color field.

Verified

  • addDate / addDateTime / addTime / addColor, each with an error → is-invalid plus a visible feedback div
  • $form->showValidation = true with no errors → is-valid, consistent with TextInput
  • Bootstrap 4 and Bootstrap 5 output
  • Inside a BootstrapRow / BootstrapCell grid cell
  • Standalone getControl() without the renderer → unchanged

make tests (150 tests), make phpstan (level 7), make cs all green. Regression tests added to DateTimeControlTest and ColorPickerTest.

🤖 Generated with Claude Code

Both controls used StandardValidationTrait but never declared
`implements IValidationInput`. BootstrapRenderer::renderControl() gates
the showValidation() call on that interface, so the input never received
`is-invalid`.

The <div class="invalid-feedback"> was emitted all along, but Bootstrap
styles it `display: none` unless a sibling input carries `is-invalid` —
so the error message was rendered yet invisible.

Affects addDate(), addDateTime(), addTime() and addColor().

Closes #113

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.94%. Comparing base (303f8eb) to head (66fda61).

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #127   +/-   ##
=========================================
  Coverage     96.94%   96.94%           
  Complexity      308      308           
=========================================
  Files            25       25           
  Lines           983      983           
=========================================
  Hits            953      953           
  Misses           30       30           

☔ View full report in Codecov by Harness.
📢 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.

Rendering a BootstrapForm resolves the presenter via lookup(); on the
lowest supported nette/application that throws when the form has no
parent, so the two new tests failed under --prefer-lowest while passing
against current dependencies.

Use the presenter-mock + non-empty action convention already used by the
renderer tests.
@dakorpar
dakorpar merged commit 104dd03 into master Aug 14, 2026
13 checks passed
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.

DateTimeControl doesn't render Validation Error Message

1 participant