netojose / laravel-bootstrap-4-forms

Bootstrap 4 forms for Laravel 5/6/7/8
MIT License
183 stars 58 forks source link

Add suppor for Date object as default for date field #52

Open str opened 5 years ago

str commented 5 years ago

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.

netojose commented 5 years ago

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?

str commented 5 years ago

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.

netojose commented 5 years ago

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.)

str commented 5 years ago

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