Reputation: 3143
{{ Form
.select('foo', {
'foo': 'bar',
}) }}
I need to apply a class based on condition. For example I have an abstract error
function that returns bool
How do I apply it like 'class' => 'error() ? 'my_class' : 'other_class'
?
I've seen this, and this <- no success
Upvotes: 1
Views: 347
Reputation: 1313
In Laravel 4:
{{ Form::select('name', ['value' => 'Label', 'another-value => 'Label'], null, ['class' => error() ? 'class' : 'another-class']) }}
In Laravel 5:
{!! Form::select('name', ['value' => 'Label', 'another-value => 'Label'], null, ['class' => error() ? 'class' : 'another-class']) !!}
Upvotes: 2