Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP form class

Tags:

validation

php

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.

like image 256
Oli Avatar asked Mar 12 '09 12:03

Oli


2 Answers

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.

like image 102
ajporterfield Avatar answered Sep 22 '22 01:09

ajporterfield


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:

  • Built in form validation (PHP and javascript)
  • Comes out of the box with integrations with jQuery UI, CKEditor/TinyMCE, Google Maps, tool tips, etc.
  • Really easy to get up and running and creating powerful forms

Cons, which eventually kept me from using it:

  • No fine grain control of form output. You can either render the whole form as a table or nothing.
  • No fieldsets

It's looks to be under active development, so might be worth keeping an eye out for future versions/improvements.

like image 26
zlovelady Avatar answered Sep 20 '22 01:09

zlovelady