I wonder if anyone can help.
I am working on a Spring/Webflow/Tiles/Thymeleaf project. All is going reasonably well. We have tiles which represent the data entry forms, typically like this:
<form th:object="${questionnaire}">
....
<select th:field="*{title}>
<option .....
</select>
....
<input th:field="*{fname}" />
<input th:field="*{lastname}" />
....
</form>
This is working well. But now we are trying to add some ajax magic to the form. Basically the idea is that when a button is pressed it triggers a webflow transition which will render its response in a tile. This is all working well ... expect the content of the fragment tile. The idea is that the new fragment will be some extra form fields. Something like this:
<div tiles:fragment="moreDetails">
....
<input th:field="*{phone}" />
<input th:field="*{email}" />
....
</div>
The webflow and tiles part is working, but when thymeleaf tries to render the tile, it complains that the form fields refer to properties with *{} syntax, but not enclosed in a form tag with th:object
So far we've come up with only 2 workarounds. We can put the form tag with th:object in the fragment tile, but this means we have a nested form in the resultant page :(
The other thing we've found we can do is simply write the input fields in the fraement with a name attribute rather than th:field
Both 'solutions' feel wrong
Does anyone know if there is a better, more thymeleaf friendly way of doing this?
Cheers
Nathan