Skip to content

Commit 2e2f41b

Browse files
committed
Fixed issue where include-form tag failed when referencing a grid
(OFBIZ-13290)
1 parent 6ef97ef commit 2e2f41b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

framework/widget/src/main/java/org/apache/ofbiz/widget/model/FormFactory.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,20 @@ public static ModelForm createModelForm(Document formFileDoc, ModelReader entity
146146
rootElement = UtilXml.firstChildElement(rootElement, "forms");
147147
}
148148
Element formElement = UtilXml.firstChildElement(rootElement, "form", "name", formName);
149+
if (formElement == null) {
150+
// look for grid definition
151+
formElement = UtilXml.firstChildElement(rootElement, "grid", "name", formName);
152+
}
153+
if (formElement == null) {
154+
throw new IllegalArgumentException("Could not find form with name [" + formName + "] in class resource [" + formLocation + "]");
155+
}
149156
return createModelForm(formElement, entityModelReader, visualTheme, dispatchContext, formLocation, formName);
150157
}
151158

152159
public static ModelForm createModelForm(Element formElement, ModelReader entityModelReader, VisualTheme visualTheme,
153160
DispatchContext dispatchContext, String formLocation, String formName) {
154161
String formType = formElement.getAttribute("type");
155-
if (formType.isEmpty() || "single".equals(formType) || "upload".equals(formType)) {
162+
if ("form".equals(formElement.getTagName()) && (formType.isEmpty() || "single".equals(formType) || "upload".equals(formType))) {
156163
return new ModelSingleForm(formElement, formLocation, entityModelReader, visualTheme, dispatchContext);
157164
}
158165
return new ModelGrid(formElement, formLocation, entityModelReader, visualTheme, dispatchContext);

0 commit comments

Comments
 (0)