New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form checkbox handling with dynamic fields #71
Comments
I think you are missing single quotes in your expression. Shouldn't... <input th:type="checkbox" th:field="*{properties[__${column.name}__]}" /> actually be: <input th:type="checkbox" th:field="*{properties['__${column.name}__']}" /> ? |
The approach works in general, also spring mvc databinding to the map. What i have to do manually is to convert the fields to the desired datatype. The resulting html is: <input type="checkbox" id="propertiesvdp" name="properties[vdp]" value="" /> Your approach produces: <input type="checkbox" id="properties'vdp'" name="properties['vdp']" value="" /> Still no databinding, still no hidden field for spring mvc. |
my current workaround is: <input th:type="checkbox" th:name="|properties[${column.name}]|" th:value="true" th:checked="${entity.properties[__${column.name}__]}"/>
<input type="hidden" th:name="|_properties[${column.name}]|" value="on" /> |
I've added tests for this at https://github.com/thymeleaf/thymeleaf-tests/blob/288e58800b4825ce5a7f630ba088928c37f66fa8/src/test-21/resources/engine21/springintegration/form/form10.thtest (also see https://github.com/thymeleaf/thymeleaf-tests/blob/288e58800b4825ce5a7f630ba088928c37f66fa8/src/test-21/resources/engine21/springintegration/form/form10.thtest ) and it works OK (adding the single quotes, which are required per the SpringEL syntax, see http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html#expressions-properties-arrays ). Does your workaround work for you, even without the quotes? Do you have a public getter method for your |
Thanks for effort and support. Yes. i have a public getter method.
entity.properties['boolField'] = true |
OK. The problem is in |
Confirmed. Thanks. I am using th:type because i determine the type dynamically. |
Fixed! Updated 2.1.4-SNAPSHOT |
I am using dynamic fields for a generic way to present entities. The actual values are in a map.
Here is a snipped from my template:
The checkbox is not bound correctly when using the pre-processing which is necessary for my dynamic fields.
Means: no hidden field is generated for spring mvc, the value in the map is not used to render the checked attribute of the input field.
The text was updated successfully, but these errors were encountered: