Enter enum value in form hidden with thymeleaf

I would like to fill the form input with a hidden one using an Enum value:

Enum:

public enum TipoEndereco {
    Residencial, Comercial
}

      

To summarize the html code, I tried to use form input like this:

<input type="hidden" th:field="*{endereco[0].tipoEndereco}" th:value="Residencial"/>

      

Unfortunately, this field is written as null. Other fields that don't use Enum in this way are written as normal. I used Enum to populate the option, but directly, as the hidden input type doesn't work. I am using thymeleaf.

+3


source to share





All Articles