Description
If you use 2 forms of the same name, with radio choice with the same name and values, then the "for" attribute is generated based on the name relative to the current form, and the index of the option.
This generated incorrect html.
The behaviour is: when you click on the label of radio items in the second form, the items in the first form are selected.
For example
class userdetailspanel extends panel {
userdetailspanel(string id) {
super(id)
Form form = new Form("testForm");
List SITES = Arrays.asList(new String[]
);
form.add(new RadioChoice("site", SITES));
}
}
class detailspage extends page {
detailspage()
}
This is because of the way the IDs are generated in RadioChoice. Specifically around
String id = getChoiceRenderer().getIdValue(choice, index);
final String idAttr = getInputName() + "_" + id;
A workaround I have has been adding a choice renderer when creating any of these RadioChoices. I have been overriding getIdValue to return something unique. (based off the housing components markupid)