Reputation: 239810
I'm used to ASPNET and Django's methods of doing forms: nice object-orientated handlers, where you can specify regexes for validation and do everything in a very simple way.
After months living happily without it, I've had to come back to PHP for a project and noticed that everything I used to do with PHP forms (manual output, manual validation, extreme pain) was utter rubbish.
Is there a nice, simple and free class that does form generation and validation like it should be done?
Clonefish has the right idea, but it's way off on the price tag.
Upvotes: 5
Views: 8277
Reputation: 48758
Here's a new one that pretty capable. In a few versions I think it could be brilliant.
http://www.html-form-guide.com/php-form/php-form-validation.html
Upvotes: 0
Reputation: 7511
A very good form validator is in the CodeIgniter project:
Read the docs and tutorial for it in their great documentation:
Upvotes: 0
Reputation: 1019
I have recently used the project listed above - http://code.google.com/p/php-form-builder-class/ - in development and noticed that the latest release (version 1.0.3) replaces the table markup with a more flexible div layout that can be easily styled to render forms however you'd like. There are many examples that can help you get started quickly.
I would recommend this project.
Upvotes: 6
Reputation: 4097
Here's another free alternative:
http://code.google.com/p/php-form-builder-class/
It lets you create a form with code like:
include("../class.form.php5");
$form = new form("form_elements");
$form->addHidden("cmd", "submit");
$form->addTextbox("Textbox:", "field0");
$form->addTextarea("Textarea:", "field1");
$form->render();
Pros:
Cons, which eventually kept me from using it:
It's looks to be under active development, so might be worth keeping an eye out for future versions/improvements.
Upvotes: 5
Reputation: 239810
The simplest solution (rather than going through the process of learning another framework) turned out to be just writing the forms and their processing code in Django and pulling their output into the PHP using CURL.
FILTHY but it was quick, has all the power of Django and it works.
Upvotes: 1