使用 Laravel Collective 选择输入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52257994/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Select input with Laravel Collective
提问by Chukwuemeka Inya
{!! Form::select('country',['1' => 'Albania','2'=>'Kosovo','3'=>'Germany','4'=>'France'],null, ['class'=>'form-control','placeholder'=>'Select Country']) !!}
This type of input doesn't take the values of the array but instead, it takes the pre-default value of option inside select.enter code here
这种类型的输入不采用数组的值,而是采用 select.enter code here 中选项的预默认值
回答by Chukwuemeka Inya
According to the Form Collective documentation, the first argument of the Form::select()
is the name
of the select
box, the second is an array
of the input
values while the third is the default
value (this could be set to null
). The fourth is an optional array of attributes/values.
This should work for you.
根据形式的集体文档,的第一个参数Form::select()
是name
所述的select
盒,第二个是array
所述的input
值,而第三个是default
值(这可以被设置成null
)。第四个是可选的属性/值数组。
这应该对你有用。
{!! Form::select('country',['Albania' => 'Albania','Kosovo'=>'Kosovo','Germany'=>'Germany','France'=>'France'],'Kosovo',['class'=>'form-control','placeholder'=>'Select Country']) !!}
回答by Leena Patel
{!! Form::select('country', [null => 'Select Country'] + ['Albania' => 'Albania','Kosovo'=>'Kosovo','Germany'=>'Germany','France'=>'France'], null, ['class' => 'form-control']) !!}
For more information : https://laravel.com/docs/4.2/html#drop-down-lists