Form validation with Ajax

Published on and tagged with ajax  documentation  tip  tutorial

I have started an FAQ article in the CakePHP Wiki about form validation with Ajax. With a simple example I show how to display messages depending on the text you enter, and how to submit your form only when all input fields are filled out correctly. Feedback is welcome!

4 comments baked

  • cyberlogi

    Hey, I copied your post (almost exaclty). It looks like it could work great, except that everytime the function ajaxValidateUsername is called in the controller, it causes my default layout to render inside the div instead of just labelText. I’ve added $this->layout = “ajax”; but it doesn’t do any good. Any ideas what i need to change in order to get it to just print the message in labelText?

    thanks

  • cakebaker

    Hm, have you tried $this->render(‘viewname’, ‘ajax’); ? Or the RequestHandler component: $this->RequestHandler->setAjax($this);

    HTH

  • Arvind Thakur

    hi as the wiki has been removed where is the information now.. as this article..

  • cakebaker

    @Arvind Thakur: You can find at least some information in the bakery (http://bakery.cakephp.org) or in the manual (http://manual.cakephp.org). And the content of the wiki is probably still available via Google’s cache. HTH

Bake a comment




(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License