generating html via using helpers

239 Views Asked by At
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO) 
    public int id;

    @Constraints.Required
    @Constraints.MinLength(1)
    @Constraints.MaxLength(30)
    public String firstName;
}

Using this class I tried to use helper:

@helper.inputText(userForm("firstName"),'placeholder->"First Name",'class->"textbox1",'required->"required")

but it generates it:

<dl id="firstName_field" class=" ">

    <dt><label for="firstName">firstName</label></dt>

    <dd>
    <input type="text" required="required" class="textbox1" placeholder="First Name" value="" name="firstName" id="firstName">
</dd>


        <dd class="info">Minimum length: 1</dd>

        <dd class="info">Required</dd>

        <dd class="info">Maximum length: 30</dd>

</dl>

My question is how to remove these:

    <dd class="info">Minimum length: 1</dd>

    <dd class="info">Required</dd>

    <dd class="info">Maximum length: 30</dd>

I don't want these extras.

I was just expecting the:

<input type="text" required="required" class="textbox1" placeholder="First Name" value="" name="firstName" id="firstName">

I am having curiosity how other developers used helpers.

1

There are 1 best solutions below

2
On BEST ANSWER

The elements you want to hide are... constraints - the same you gave as annotations to your model and/or Form class.

If you took a look into templating docs you would see, there is possibility to disable them with '_showConstraints -> false.

Of course you can write your own helpers and/or use direct HTML markup for generating forms.