How set null to first option in Laravel 5 blade

2019-08-05 18:17发布

问题:

here is laravel blade selectyears which generates select from 2013 to 2015 and need set first option to null.

{!! Form::selectYear('year', 2013, 2015) !!}

回答1:

Just have another array array(''=>"Select Year") in your select

I guess that you need null because you might need to place some text like Select Year like that.

Here is What you need

{!! Form::select('year', range(2013, 2015) + array(''=>"Select Year")) !!}