Date Picker Placeholder

I'm trying to set up a placeholder for a Date Picker input inside a form, but it does not seem to work, even though the documentation for v3 says it should. I have tried passing a datetime string, a Carbon date, but to no avail. Thanks in advance for your help!
8 Replies
awcodes
awcodes14mo ago
What code are you trying?
valentin_morice
valentin_moriceOP14mo ago
DatePicker::make('starts')->placeholder(Carbon::now()->toDateString) I tried passing the Carbon object itself, and hardcoded a simple datetime string. I also tried a string that matches the formatting on the front-end (because why not), but it did not work either.
awcodes
awcodes14mo ago
Placeholder seems weird to me on a DatePicker. But maybe try it as a callback. ->placholder(fn () => now()->toDateString()) I’m not even sure a date picker has a placeholder at the html level.
valentin_morice
valentin_moriceOP14mo ago
You're right, seems like placeholder don't apply to date pickers. Thought I saw it in the documentation, but I realized it was v1, not v3.
awcodes
awcodes14mo ago
Maybe you could get what you want with ->default() but that will only work in the create context.
valentin_morice
valentin_moriceOP14mo ago
It does work with default, but somehow the value is set only after the state is mutated on the front-end.
awcodes
awcodes14mo ago
So, set it in afterStateHydrated() If null set the state to now()
valentin_morice
valentin_moriceOP14mo ago
OK, I've got the behavior I wanted. Thank you so much for your help, have a great day!
Want results from more Discord servers?
Add your server