m.put("myforms[0]-subject", new String[] {"hello"});
m.put("myforms[0]-message", new String[] {"Hi there"});
m.put("myforms[1]-subject", new String[] {"hello"});
m.put("myforms[1]-message", new String[] {"Hi there"});
InlineForms forms = formFactory.inlineForms("myforms");
forms.add(injector.getInstance(ContactForm.class).bind(m));
forms.add(injector.getInstance(ContactForm.class).bind(m));
int ctr = 0;
for (Form form : forms) {
assertTrue(form.isValid()); // is valid must be called before a bound form can be rendered.
assertEquals(
String.format("<tr><th><label for='id_myforms[%1$d]-subject'>Subject</label></th><td><input id=\"id_myforms[%1$d]-subject\" type=\"text\" name=\"myforms[%1$d]-subject\" value=\"hello\" /></td></tr>\n" +
"<tr><th><label for='id_myforms[%1$d]-message'>Message</label></th><td><input id=\"id_myforms[%1$d]-message\" type=\"text\" name=\"myforms[%1$d]-message\" value=\"Hi there\" /></td></tr>\n",
ctr++), form.asTable());
}
assertEquals(ctr, 2);
Iterator<BoundField> boundFields = forms.getControlFields();
assertEquals("<input id=\"id_myforms_CTRL-fieldCount\" type=\"hidden\" name=\"myforms_CTRL-fieldCount\" value=\"2\" />",boundFields.next().toString());
}