We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

AJAX forms

Phalcon have form validation and filtering functionality that designed for using as non-AJAX forms. Is there some 3rd-party wrappers for comfortable using Phalcon for JSON serialized data validation from Phalcon-generated forms?

edited Feb '16

Correct me if I'm wrong, but can't your AJAX send the data as POST and validate it like a regular form?

Here is a simple example:

 $form = YourForm();   
 if ($form->isValid($this->request->getPost())) {  

 // or if your content comes as json
 $data = json_decode($jsonData);
 if ($form->isValid($data)) { 

Some JQuery I reuse/modify when sending ajax forms (it works on all kind of frameworks):

$.ajax({
  url: $('formSelector').attr('action'),
  data:  $('formSelector').serialize(),
  type: 'POST',
  dataType: 'json',
  success: function($data){
    // blabla
  }
});
edited Feb '16

Of course I can. But I want true REST API style AJAX communication. I.e. after all client-side validations form generated via Phalcon forms

<form>
 <input type="text" name="abc" value="def" />
 <input type="text" name="xxx" value="yyy" />
</form>

will be converted on UI to

{
    "abc": "def",
    "xxx": "yyy"
}

and will be sent to server for validation also via Phalcon forms component.