laravel-bootstrap-4-forms icon indicating copy to clipboard operation
laravel-bootstrap-4-forms copied to clipboard

Add suppor for Date object as default for date field

Open str opened this issue 6 years ago • 4 comments

I'm trying to set the DateTime object as param as default for the Form::date() helper, without success.

$date = new \DateTime('tomorrow');
{!! Form::date('date', 'Matches for date:', $date) !!}

Should we add suport for that?

Current workardound is $date->format('Y-m-d'), but should not.

str avatar Jan 28 '19 16:01 str

Hi @str , is a good idea. But the package doesn't know the desired format to be applied to "stringify it". Do you have some suggestion?

netojose avatar Jan 28 '19 16:01 netojose

The required format for the input[type=date] is 'Y-m-d'. The format to be shown to the user is selected by the browser depending on the user's locale.

str avatar Jan 28 '19 17:01 str

Cool, thanks! I will implement this. I'm working in a new version (just refactoring the FormBuilder class) and I will add this (maybe available in 5 days.)

netojose avatar Jan 28 '19 17:01 netojose

BTW, great project. I don't understand why aren't there any projects like this.

str avatar Jan 28 '19 18:01 str