StringBuilder hidden_fields = new StringBuilder();
for (Entry<String, Field<?>> entry : getFields().entrySet()) {
Field<?> field = entry.getValue();
String fieldName = field.getName() == null ? entry.getKey() : field.getName();
BoundField bf = new BoundField(field, this, fieldName);
// any class attributes that should be applied to the table row.
String cssClasses = bf.getCssClasses();
String htmlClassAttr = cssClasses == null ? "" : String.format(" class=\"%s\"", cssClasses);
if (bf.isHidden()) {
hidden_fields.append(bf.toString());
hidden_fields.append("\n");
} else {
StringBuilder errors = new StringBuilder();
if (this.getErrors().get(fieldName) != null) {
errors.append("<ul class=\"errorlist\">");
errors.append("<li>");
errors.append(this.getErrors().get(fieldName)); // when this goes to a list, use bf.geterorrs instead of this.
errors.append("</li>");
errors.append("</ul>");
}
b.append(String.format("<tr%s><th>%s</th><td>%s%s%s</td></tr>\n", htmlClassAttr, bf.getLabelHtml(), errors.toString(), bf.toString(), bf.getHelpText()));
}
}
if (hidden_fields.length() ==0 ) { // no hidden fields
return b.toString();
} else if (b.length() > 11) { // insert hidden field into the last cell of the table.