Skip to content

Fix custom datepicker show field validation#19829

Merged
danharrin merged 6 commits into
filamentphp:4.xfrom
wychoong:fix/custom-datepicker-input-validation
May 22, 2026
Merged

Fix custom datepicker show field validation#19829
danharrin merged 6 commits into
filamentphp:4.xfrom
wychoong:fix/custom-datepicker-input-validation

Conversation

@wychoong
Copy link
Copy Markdown
Contributor

@wychoong wychoong commented May 8, 2026

Description

#19788

when using custom datetime pickerm if filled with time that is not passed with the html validation, it fails html validation and not focusable
console error when try to save form

An invalid form control with name='' is not focusable.   <input max="59" min="0" step="15" type="number" inputmode="numeric" x-model.debounce="minute">
   $this->form->fill([
            'started_at' => now()
                ->minute(18)
                ->hour(3)
                ->second(30),
        ]);
        
DateTimePicker::make('started_at')
        ->label('Started At')
        ->seconds(false)
        ->native(false) // without this the form can save without issue
        ->secondsStep(20)
        ->hoursStep(2)
        ->minutesStep(15),

Visual changes

the fix proposed in this PR does the following:

  • open the panel and retrigger the html validation
  • validate on blur for hour/minute/second inputs

this PR does not

  • validate on panel close
  • server side validation for hour/minute/second
image

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@github-project-automation github-project-automation Bot moved this to Todo in Roadmap May 8, 2026
@danharrin danharrin added the bug Something isn't working label May 10, 2026
@danharrin danharrin added this to the v4 milestone May 10, 2026
@danharrin
Copy link
Copy Markdown
Member

Couple of changes before this can land:

  • Move the x-data body into packages/forms/resources/js/components/date-time-picker.js rather than inlining it in the Blade view. Wire it via x-data="dateTimePickerFormComponent({...})" like the rest of the file.
  • Switch @invalid / @blur to x-on:invalid / x-on:blur — the project standard.

@wychoong
Copy link
Copy Markdown
Contributor Author

Couple of changes before this can land:

  • Move the x-data body into packages/forms/resources/js/components/date-time-picker.js rather than inlining it in the Blade view. Wire it via x-data="dateTimePickerFormComponent({...})" like the rest of the file.
  • Switch @invalid / @blur to x-on:invalid / x-on:blur — the project standard.

done

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Roadmap May 22, 2026
@danharrin danharrin linked an issue May 22, 2026 that may be closed by this pull request
@danharrin danharrin merged commit 91aee74 into filamentphp:4.x May 22, 2026
23 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Roadmap May 22, 2026
@wychoong wychoong deleted the fix/custom-datepicker-input-validation branch May 22, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

datepicker failed to save with validation

2 participants