How to add button to Datetimepicker?

Hello, I have a datetimepicker added to one of my forms and I am looking to add a button to click when I am done selecting date and time. The default datetimepicker lets us select the date and time and then we have to click away to be able to update the input, also there is an option to close it automatically after date and time selection, but what I need is to add a button to update the input and close the picker. Please let me know is it possible to do so? Thank you
No description
5 Replies
Mohamed Ayaou
Mohamed Ayaou3d ago
this is not a filament specific thing, it is just the default HTML Datepicker behavior
Mohamed Ayaou
Mohamed Ayaou3d ago
But I think filament has a ready to use method that may help you: https://filamentphp.com/docs/3.x/forms/fields/date-time-picker#closing-the-picker-when-a-date-is-selected
DateTimePicker::make('date')
->native(false)
->closeOnDateSelection()
DateTimePicker::make('date')
->native(false)
->closeOnDateSelection()
mohdaftab
mohdaftabOP2d ago
@Mohamed Ayaou thank you for the reply, the closeOnDateSelection only works when there is no time involved in the picker. bump
Mohamed Ayaou
Mohamed Ayaou2d ago
You need some javascript to edit the html input behaviour, just search for it and inject it with filament assets
mohdaftab
mohdaftabOP2d ago
@Mohamed Ayaou thank you, I will try it this way.

Did you find this page helpful?