javascalafieldplayframework-2.0hidden

Play 2.0 generate hidden field without div wrapper


Am generating a hidden fields like so:

@helper.input(_form("userID"), '_label-> None) { (id, name, value, args) =>
  <input type="hidden" name="@name" id="@id" value="@value" @toHtmlArgs(args)>
}

Which works fine except for the fact that the div wrapper block element is created, which creates visual empty space in the form, not looking good -- how to make hidden input elements display without div wrapper?

I know I can jQuery hide the parent div wrapper, but I'd like to not generate it in the first place.


Solution

  • You don't need to use a @helper.input in this case. Try this:

    @defining(_form("userID")) { uidField =>
      <input type="hidden" name="@uidField.name" id="@uidField.id" value="@uidField.value">
    }