PDA

View Full Version : Validate on dynamic form



atula_a1
29 Sep 2011, 11:45 PM
Hi all,
I have building an webapp by use Sencha touch.
My add form is dynamic form, depend actions it render differences element form.


//add elements
function addFrom()
{
if(action == 1)
{
formAdd.add({
label: 'productID',
name: 'productID',
xtype: 'textfield',
id: 'productID'
});

formAdd.add({
label: 'Name',
name: 'name',
xtype: 'textfield',
id: 'name'
});
.............
}
else if(action ==2)
{
formAdd.add({
label: 'productID',
name: 'productID',
xtype: 'textfield',
id: 'productID'
});

formAdd.add({
label: 'Quantity',
name: 'quantity',
xtype: 'textfield',
id: 'quantity'
});
.............
}
}

Normal in sencha touch . we validate by use property validations in Model
http://www.sencha.com/learn/using-validations-and-associations-in-sencha-touch
But Form is dynamic , cannot define a specific Model for it.
If in Ext js, solution is each element has it own regular expression


formAdd.add({
fieldLabel: 'Quantity',
regex: 'regex',
msgTarget : 'under',
id: 'quantity'
});


Use sencha touch, Has an solution does the same?

Someone help me!
Thank advance!