samedi 12 septembre 2020

Spring Thymeleaf Form of Map that contains another map

I'm trying to create a generic form (Map<String, Object>) but this map could contain another map in one of its values.

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TypeMap {
    Map<String, Object> data;
}

and here is my current thymeleaf HTML:

<div class="col form-group">
    <input type="text" th:field="*{data['__${field.name}__'['__${language.code}__']]}" />
</div>

when I inspect this input element it has the attribute name=data['name'['en']] but when I submit the form, it doesn't fill in the map data.name, but it creates a new entry in data with the key name[en].

Note: I tried many other things including removing the quotation.

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire