|
Hi,
I have multiple groups of radio buttons in my form and I need to selected values inside an array. when I set the th:field property it replaces the name attribute. Whatever I set to name it replaced by th:field attribute which results in having only one radio button group for the whole form. I replicated the same. Can someone suggest what to do here so that it shoudn't replace the name attribute. Or it is the expected behaviour. I am new to thymeleaf and didn't find any answer to this problem
<ul> <li th:each="radioValue,s: ${singleSelectAllValues}"> <input type="radio"
th:field="*{multiRadioSelectedValues}"
th:name="${'first'}"
th:id="${'first'+s.count}"
th:value="${radioValue}" /> <label
th:text="${radioValue}"></label> </li> </ul> <div>second</div> <ul> <li th:each="radioValue,s: ${singleSelectAllValues}"> <input type="radio"
th:field="*{multiRadioSelectedValues}"
th:name="${'second'}"
th:id="${'second'+s.count}"
th:value="${radioValue}" /> <label
th:text="${radioValue}"></label> </li> </ul>
the form backing object is
import lombok.Data;
@Data
public class FormCommand {
String textField;
String textareaField;
String datetimeField;
String colorField;
boolean singleCheckboxField;
String[] multiCheckboxSelectedValues;
String radioButtonSelectedValue1;
String radioButtonSelectedValue2;
String[] multiRadioSelectedValues;
String dropdownSelectedValue;
}
|