@@ -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