PDA

View Full Version : Unable to server side validate/markInvalid() fields created in JSON



JohnJones357
28 Aug 2014, 9:54 AM
I have a form that has a set of dynamic fields. When a selection is made from a combo, I make a request and server sends textfields in the JSON response:



{"data":[{
"items":[{
"allowBlank":false,
"xtype":"textfield",
"name":"DynamicField1",
,"fieldLabel":"DynamicFld"
}]
}]
}

i then take this response and add it to a container in my form.

On form submit( ), I return a dummy JSON :


{"success":false, "errors":{"DynamicField1":"Error Message"}

this has no effect at all. It does not highlight the field nor display the error message.

This does not work either:


this.getMyForm().getForm().findField("DynamicField1").markInvalid("my error message");

However, these two approaches above work perfectly fine for all my textfields in that form that are NOT dynamic.

So, is server side validation failing because the fields are created in the JSON? And if so, is there a possible solution for this?

thanks!!

mitchellsimoens
4 Sep 2014, 8:01 AM
How are you adding them to the form? If using form.add then it doesn't know where it came from.