问题
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