form.setProperty("url", "?_a=submit&_callback="+callback+"&_setting="+StringEscapeUtils.escapeHtml(callbackSetting)+"&_submitButtonLabel="+StringEscapeUtils.escapeHtml(buttonLabel));
if(form != null){
//if id field not exist, automatically add an id hidden field
Element idElement = FormUtil.findElement(FormUtil.PROPERTY_ID, form, formData);
if (idElement == null) {
Collection<Element> formElements = form.getChildren();
idElement = new HiddenField();
idElement.setProperty(FormUtil.PROPERTY_ID, FormUtil.PROPERTY_ID);
idElement.setParent(form);
formElements.add(idElement);
}
// create new section for buttons
Section section = new Section();
section.setProperty(FormUtil.PROPERTY_ID, "section-actions");
Collection<Element> sectionChildren = new ArrayList<Element>();
section.setChildren(sectionChildren);
Collection<Element> formChildren = form.getChildren(formData);
if (formChildren == null) {
formChildren = new ArrayList<Element>();
}
formChildren.add(section);
// add new horizontal column to section
Column column = new Column();
column.setProperty("horizontal", "true");
Collection<Element> columnChildren = new ArrayList<Element>();
column.setChildren(columnChildren);
sectionChildren.add(column);
Element hiddenField = (Element) pluginManager.getPlugin(HiddenField.class.getName());
hiddenField.setProperty(FormUtil.PROPERTY_ID, "_json");
hiddenField.setProperty(FormUtil.PROPERTY_VALUE, json);
columnChildren.add((Element) hiddenField);
Element submitButton = (Element) pluginManager.getPlugin(SubmitButton.class.getName());
submitButton.setProperty(FormUtil.PROPERTY_ID, "submit");
submitButton.setProperty("label", buttonLabel);
columnChildren.add((Element) submitButton);
}
// generate form HTML
String formHtml = null;