PDA

View Full Version : Form Validation with ExtJS and CakePHP



nima1
27 Mar 2010, 5:52 AM
Hi,
i have a simple extJS Form with two TextFields. The data is send to an action of a cakePHP controller. Before the data is written in to the data base, it is validated by the model. If something went wrong, the controller sends a json response to the extJS form. The json looks like:


{success:false, errors:{"serial":"Entered serial allready in Database","pa":"Incorrect Format. Has to be PA-1234 or PA-12345 "}}

Its possible to access the error with the following code:


failure: function(form, action) {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.MessageBox.alert('Message', 'Error :-(' + obj.errors.serial);
}

The code is part of the Submit button handler.
But i don't want the error messages in a MessageBox.
I want to write the error message under the textFiled where the error happen.
The id's of the textFields are the same than in the error json sting. (serial and pa)

I hope you understand me :D

Please excuse my english, i know its not the best. But i'm learning :-)

Thanks to all of you,
nic

duderion
21 Mar 2012, 11:22 PM
BUMP!