如何在Laravel 5 Blade中将null设置为第一个选项 [英] How set null to first option in Laravel 5 blade
本文介绍了如何在Laravel 5 Blade中将null设置为第一个选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是laravel刀片选择年份,该年份生成从2013年到2015年的选择,需要将第一个选项设置为空.
here is laravel blade selectyears which generates select from 2013 to 2015 and need set first option to null.
{!! Form::selectYear('year', 2013, 2015) !!}
推荐答案
只需在选择中包含另一个数组array(''=>"Select Year")
Just have another array array(''=>"Select Year")
in your select
我猜您需要为null,因为您可能需要像这样放置Select Year
之类的文本.
I guess that you need null because you might need to place some text like Select Year
like that.
这就是您需要的
{!! Form::select('year', range(2013, 2015) + array(''=>"Select Year")) !!}
这篇关于如何在Laravel 5 Blade中将null设置为第一个选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文