New version 2.0.2 available!
Please read the changelog before downloading and upgrading
Welcome to the home of the Form Generation Library, a project that will help you to accelerate your form creation and reduce your coding efforts.
The Form Generation Library is based on the idea of Benjamin Midget’s Midget Forms (which is no longer actively developed) and is maintained and developed by Frank Michel. I am always looking forward to code improvements or bug reports, so if you find anything please let me know [info at frankmichel dot com]! I’d love to include it in the next release.
The library is generating valid XHTML and utilizes CI’s form validation including the support of custom callback functions. Take a look at the demo form.
I have developed a user guide that gives you some help in understanding how the library works.
If you download the files you will also find lots of comments that will explain how to use the library and its methods. You can choose between two download options (with or without user guide).
Please see the user guide for installation guidelines.
The user guide also provides important information about the config file and usage of the various form elements.
Last, but not least please take a look at the release notes to keep up with the latest updates and changes.
I hope you enjoy the library and help to make it even better. If you’re using it for commercial projects I would appreciate a small donation. As a thank you please grab one of the Form Generation Library Quick Reference guides.
I knew this one would draw attention But the good news is that it really is true and I am working hard to release it asap. The inspiration came from Benjamin Midget’s MidgetForms which was a great approach but unfortunately never got to version 1.0. Since i needed form generation asap i decided to build a library myself.
I added error handling today so the script auto validates the code and checks for correct syntax when adding elements to the form.
As a sneak peek these are the element methods which will be available in the library:
To add an element id you can pipe the name parameter like “elname|elid” where the id is an optional parameter. If an id is mandatory (such as for a label’s for attribute) and you didn’t specify it the library will automatically generate a unique id for you.
Moreover there will be lots of methods to add classes, rules, errors, attributes, etc.
I knew this one would draw attention But the good news is that it really is true and I am working hard to release it asap. The inspiration came from Benjamin Midget’s MidgetForms which was a great approach but unfortunately never got to version 1.0. Since i needed form generation asap i decided to build a library myself.
I added error handling today so the script auto validates the code and checks for correct syntax when adding elements to the form.
As a sneak peek these are the element methods which will be available in the library:
To add an element id you can pipe the name parameter like “elname|elid” where the id is an optional parameter. If an id is mandatory (such as for a label’s for attribute) and you didn’t specify it the library will automatically generate a unique id for you.
Moreover there will be lots of methods to add classes, rules, errors, attributes, etc.
Very cool. One of these days I need to get around to doing this for myself, as I invision validation / form configuration working seemlessly together. This is what I am looking to do:
$fields = array( array('type' => 'input', 'name' => 'test', 'id' => 'test', 'label' => 'Test Input:', 'class' => 'field', 'attr' => '', 'default' => 'Default Value', 'max_length' => '50',// If set, will also set validation rule automatically to max_length 'rules' => 'required|callback__validateTest'),
array('type' => 'select', 'name' => 'test2', 'id' => 'test2', 'label' => 'Test Select 2:', 'class' => 'select', 'attr' => '', 'default' => '0', 'lookups' => array('0' => 'value 1', '1' => 'value 2'),// form validation will now check for what has been posted and verify it is in this array key 'rules' => 'required|callback__validateTest'), ); $form = create_form('form_name', 'action', 'id="bob"|style="width:234px;"', $fields);
That’s my dream anyways. Views would pretty much be obsolete as they are all configured in the controller. Just the standard view_form view could be called.
Let me give you a usage example for the form in the previous post:
First of all, in the config file you would set “name_as_id” to TRUE, so all names will be converted to id’s (if applicable). So no need to manually provide id’s for all the elements (you can still do if you like, though).
$select = array('value 1', 'value 2', 'value 3'); // no need to provide keys since they start with 0
That’s it. Of course you could put the classes in the config file to save you some typing. Oh and my approach with maxlength was the other way around. If you apply a maxlength validation rule the library will automatically set the maxlength attribute for you.
Sorry I haven’t been posting in a while. I was traveling and just got back to working on the library. I am currently testing it and refining the code. I am also working on a user guide which will explain all methods and element usage.
I used some different configurations, label positioning as well as error display (on top, inline as image with title, inline as text). Since I saw some requests about error messages per field (opposed to per rule) I have also added this feature. You can see it in action if you delete the default content in the “Notes” textarea and then post the form.
The user guide is available here, but still needs work on lots of the pages. But you can go ahead and check out the element usage which is almost already finished.
As soon as I will release the first version of this library I am happy about receiving your feedback and inputs.