PDA

View Full Version : Build Dynamic form using XML Defintion



abarhoum
8 Apr 2013, 3:06 AM
Hello all
I'm trying to build dynamic Extjs form, i have XML definition for each field in this form. so can i pass this XML to the form and build it automatically, or should i do that by my self ? below is the sample of XML defintion :

<Fields>
<Field id="12" name="filedName1" type="text" required="true">
<Label>Field #1</Label>
<ErrorMessage>this field can't be empty</ErrorMessage>
<DefaultValue><![CDATA[]]></DefaultValue>
</Field>
</Fields>

Thanks.

Arg0n
8 Apr 2013, 3:59 AM
ExtJs can read simple XML into a store (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.XmlStore). You would need something to parse it into json. Then you could pass it to the form and generate the fields.
But you would need to write something to parse it etc.

abarhoum
8 Apr 2013, 1:22 PM
Thanks ArgOn, actually i'm going to change my form to JSON and using Decode method to parse it. Thanks alot :)

Arg0n
8 Apr 2013, 1:37 PM
But, I would not recommend this. I also generated whole extjs components in php. This leads to bad code, which is hard to read and even harder to debug. So think about it ;P

abarhoum
8 Apr 2013, 1:43 PM
I know what do you mean. but i have only one template for now with two types of field . so i will change it manually to JSON, after that i will use Decode method.