1
{{ 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

Community
  • 1
  • 1
knitevision
  • 3,023
  • 6
  • 29
  • 44

1 Answers1

2

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']) !!}
noodles_ftw
  • 1,293
  • 1
  • 9
  • 17