{{ Form
.select('foo', {
'foo': 'bar',
}) }}
我需要根据条件应用一个类。例如,我有一个抽象的error
函数,它返回bool
我如何像'class' => 'error() ? 'my_class' : 'other_class'
一样应用它?
我已经看到了这个,这<- 没有成功
在 Laravel 4 中:
{{ Form::select('name', ['value' => 'Label', 'another-value => 'Label'], null, ['class' => error() ? 'class' : 'another-class']) }}
在拉拉维尔5中:
{!! Form::select('name', ['value' => 'Label', 'another-value => 'Label'], null, ['class' => error() ? 'class' : 'another-class']) !!}