Is there a well tested and preferably mature library out there for creating forms in PHP with both client side (this is where the jQuery comes in) and server side validation?
Ideally the form would either be generated from PHP classes or written as plain HTML and parsed ala Agavi. The correct jQuery hooks would then automatically be created by the library so that the included jQuery client side validation can run.
One of the jobs I do regularly is some variation on the good old contact form and I would like to standardise this work so that I can trot out the same best practice code each time. With this in mind the HTML generated by the PHP classes should be good enough so that extra CSS hooks can be added where needed etc.
Any suggestions gratefully received.
I have been combing through and reviewing the options that I have found and that others have suggested below and at the moment I would rank the projects in the following order for quality from the small amount of testing and research I have done on all of them.
I am still unconvinced by any of the options to be honest and I am left wondering why people who embark on these projects do not start with some solid and well tested components. For example I would have thought a combination of:
Would give you a good stable base to work from and produce a nice library on top of tested components.
Also if you are interested in a library that parses your HTML rather than generating the HTML from a PHP class I have found a project called Minacl. Like the Agavi option I mentioned in the original question.
You can use ValidForm Builder. It matches perfect to your requirements: With it you can define Forms with validation rules in PHP, and it generates the Forms with jQuery and client side validation.
Feature List (taken from their site):
UPDATED for 2017
Agile UI is a PHP UI component library (and successor of atk4.3) including things like:
All components have a consistent and simple PHP interface:
$form = new \atk4\ui\Form();
$layout->add($form);
$form->setModel(new Country($db));
If you prefer CRUD just use \atk4\ui\CRUD. Agile UI also offers tools for adding custom components.
Comparing with alternative software:
$form->render() or for entire web app.What exactly are the problems with running client-side validation in HTML_QuickForm2?
It needs a quickform.js file to work. The file is installed with the package but is not automatically included in the form output. I've recently updated the docs to make this issue more obvious.
Also QF2 had a couple of releases since your question, a few JS-related bugs were squashed. Consider giving it another try: we are targeting a stable release Really Soon Now and would love feedback.