问题
Using Laravel 4's Form class, we can create a list using
{{ @Form::select('colors', Colors::all()), $color }}
Question: How can we add the attribute disabled
using Blade without having to rewrite the clean Blade syntax into the usual ugly form?
回答1:
Just add array('disabled')
in the end like:
{{ Form::select('colors', Colors::all(), $color, array('disabled')) }}
回答2:
This should do the work.
{{ @Form::select('colors', Colors::all()), array(
'disabled' => 'disabled',
'class' => 'myclass'
) }}
回答3:
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.
来源:https://stackoverflow.com/questions/17739699/using-laravel-form-class-to-add-the-disabled-attribute