简体   繁体   English

使用Laravel Collective选择输入

[英]Select input with Laravel Collective

{!! Form::select('country',['1' => 'Albania','2'=>'Kosovo','3'=>'Germany','4'=>'France'],null, ['class'=>'form-control','placeholder'=>'Select Country']) !!}

这种类型的输入不接受数组的值,而是在select.enter代码中使用选项的预置默认值

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 ). 根据Form Collective文档Form::select()的第一个参数是select框的name ,第二个是input值的array ,而第三个是default值(可以设置为null ) 。 The fourth is an optional array of attributes/values. 第四个是可选的属性/值数组。
This should work for you. 这应该适合你。

{!! Form::select('country',['Albania' => 'Albania','Kosovo'=>'Kosovo','Germany'=>'Germany','France'=>'France'],'Kosovo',['class'=>'form-control','placeholder'=>'Select Country']) !!}
{!! Form::select('country', [null => 'Select Country'] + ['Albania' => 'Albania','Kosovo'=>'Kosovo','Germany'=>'Germany','France'=>'France'], null, ['class' => 'form-control']) !!}

有关更多信息,请访问: https//laravel.com/docs/4.2/html#drop-down-lists

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM