views:

278

answers:

2

I want to make a edit profile form for my website.
My idea is getting JSON object and after user updates the data, I will use Ajax to send the request to update the database.

Here is the question.
I want to use the Zend validator to validate the form.
How can I use it when I use ajax to submit data?

+1  A: 

Same :)

you send JSON array (comming from the form) and it can be validate like $form->isValid(Zend_Json::decode($array));

Tomáš Fejfar
A: 

$json = $form->processAjax($_POST);

You can then simply send the JSON response to the client. If the form is valid, this will be a boolean true response. If not, it will be a javascript object containing key/message pairs, where each 'message' is an array of validation error messages.