2016-04-05 5 views
1
{{ Form 
.select('foo', { 
    'foo': 'bar', 
}) }} 

Мне нужно применить класс на основе условия. Например, у меня есть абстрактная функция error, которая возвращает boolLaravel 4 Форма Выберите: применить условный класс

Как применить его как 'class' => 'error() ? 'my_class' : 'other_class'?

Я видел this и this < - нет успеха

ответ

1

В Laravel 4:

{{ Form::select('name', ['value' => 'Label', 'another-value => 'Label'], null, ['class' => error() ? 'class' : 'another-class']) }} 

В Laravel 5:

{!! Form::select('name', ['value' => 'Label', 'another-value => 'Label'], null, ['class' => error() ? 'class' : 'another-class']) !!} 
Смежные вопросы