Using Laravel Form class to add the 'disabled' attribute for some options

左心房为你撑大大i 提交于 2020-01-23 21:39:32

问题


Using Laravel 4's Form class, I have this list:

{{ Form::select('set', $sets, $prod->set_id, array('class' => 'form-select')) }}

How can I add the attribute disabled only for some options?


回答1:


Try this;

{{ Form::select('set', $sets, $prod->set_id, array('class' => 'form-select', 'disabled')) }}

The last parameter you pass will end up being the HTML attributes. And you cannot restrict it for only some options. You can only disable the input field. If you don't want certain options omit them from your $set variable before passing to the view.




回答2:


The Form::select not has support for extra properties in the options. In the max, you can modify the 'value', name and the attribute 'selected'.

You have that do this using your own function or manually with HTML.



来源:https://stackoverflow.com/questions/24635869/using-laravel-form-class-to-add-the-disabled-attribute-for-some-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!