Input an enum value in a form as hidden using thymeleaf

Viewed 312

I would like to fill an form input hidden using a value of an Enum:

Enum:

public enum TipoEndereco {
    Residencial, Comercial
}

Summarizing the html code, i've tried to use the form input like this:

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

But unfortunately, this field is being recorded as null. The others fields that don't use Enum in this way, are being recorded normal. I've used Enum to fill an option, but directly as input type hidden isn't working. I'm using thymeleaf.

0 Answers
Related