Using Laravel Form class to add the 'disabled' attribute

本秂侑毒 提交于 2019-12-03 22:16:53
JustinHo

Just add array('disabled') in the end like:

{{ Form::select('colors', Colors::all(), $color, array('disabled')) }}

This should do the work.

 {{ @Form::select('colors', Colors::all()), array(
    'disabled' => 'disabled',
    'class'    => 'myclass'
    ) }}

Though already answered, IMO both answers weren't neutral enough, so to avoid duplicates the arguments are @Form::select('name', $optionsArray, $selectedOption, ['disabled']).

So if you're prepopulating form with @Form::model() you should do @Form::select('name', $optionsArray, null, ['disabled']) - array with 'disabled' has to be 4th parameter.

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