How to achieve dynamic class in input helper


#1

Here is a very common scenario:

dynamically change the text input’s class based on the state(hasError or not).

if it is a normal html tag, this can be achieved with if helper inside class declaration:

<input type="text" class="{{if errors.name "error"}}">

note: errors.name is just a property from controller.

but with input helper, this will cause a building error.

so how can I achieve dynamic class in input helper?


#2

{{input type='text' value='foobar' class=(if showYellow 'yellow' 'blue')}}