添加类以在 Laravel 上选择元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26831509/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:24:23  来源:igfitidea点击:

Add Class to select element on Laravel

phplaravelblade

提问by Iván F

I have this problem, I can't find the way to add class attribute in this Dropdown box

我有这个问题,我找不到在这个下拉框中添加类属性的方法

{{Form::select('bancada', Bancada::lists('nombre','idBancada'))}}

I have tried various syntax, but can not get it to work.

我尝试了各种语法,但无法让它工作。

Any suggestions? Thanks

有什么建议?谢谢

回答by Marwelln

Use the forth parameter to add attributes to your element.

使用第四个参数为元素添加属性。

{{Form::select('bancada', Bancada::lists('nombre','idBancada'), null, ['class' => 'my_class'])}}

Take a look at the source($optionsis the same as attributes for your element).

查看源代码$options与元素的属性相同)。

回答by Nikunj K.

{{ Form::select('status', $statusList, null, array('class' => 'form-control')) }}

In above example you can add class as fourth parameter

在上面的示例中,您可以添加类作为第四个参数