Laravel - Select - set default option

I have a little problem with my favorite forms using Laravel.

{!! Form::selectRange('day', 1, 31, null, ['class' => 'form-control']) !!}
{!! Form::selectMonth('month', null, ['class' => 'form-control']) !!}
{!! Form::selectYear('year', Carbon\Carbon::now()->year, (new Carbon\Carbon('80 years ago'))->year, null , ['class' => 'form-control']) !!}

      

This gives me:

aa

This is fine, except that most people leave them as they are when registering.

I want them to display "year", "day", "month" by default, so the user has to select from a list.

Any ideas how to implement this.

+3


source to share


1 answer


If you now have twice null

and the last current year of Datetime Carbon, these are the places in the methods that will show the parameter default

.



But ... The values ​​you want must also be in the data source it shows.
With these helpers you are using, it is not. This article from laravel itself shows more information on this and how to fix it.

0


source







All Articles