Adding class to input in Play 2 custom FieldConstructor

Viewed 2272

I am making a custom field constructor in Play 2:

@(elements : helper.FieldElements)

<div class="@if(elements.hasErrors) {error}">
    <label for="@elements.id">@elements.label</label>
    <div class="input">
        @elements.input
        <span class="errors">@elements.errors.mkString(", ")</span>
        <span class="help">@elements.infos.mkString(", ")</span>
    </div>
</div>

I need the input element to always have a particular class "my-class". How can I do this? The FieldElements class has an args member. I tried making a copy of the elements with " my-class" appended to the value associated with '_class in args, but this did not seem to affect the input element.

4 Answers
Related