ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Form Generation Library

March 06, 2009 12:43pm

Subscribe [120]
  • #1 / Mar 06, 2009 12:43pm

    macigniter's avatar

    macigniter

    244 posts

    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.

    Cheers,
    Frank

    IMPORTANT:
    Verson 2.0 requires CodeIgniter > 2.0.0

    Verson 1.0 includes major udpates and changed syntax in various places. Please read the upgrade instructions on the download page.

    Version 0.1.5 changes the way the config file is set-up. Please read the user guide and change your existing config files to match the new standard.

  • #2 / Mar 06, 2009 1:05pm

    brianw1975's avatar

    brianw1975

    257 posts

    I’m very interested in this, please keep us (or me) posted.

  • #3 / Mar 06, 2009 1:29pm

    abmcr's avatar

    abmcr

    254 posts

    Wow!!!! i’m very interest also

  • #4 / Mar 06, 2009 1:41pm

    Tom Schlick's avatar

    Tom Schlick

    386 posts

    Post the PHP file or its not true!!! haha jk but i would be happy to test it out for you and give feedback.

  • #5 / Mar 06, 2009 2:18pm

    Fero's avatar

    Fero

    54 posts

    I only hope it’s true, I’ll kiss the ground you walk for this one!

  • #6 / Mar 06, 2009 8:01pm

    Colin Williams's avatar

    Colin Williams

    2601 posts

    Been wanting to do this myself for some time now. There are other versions out there, but I’ll be interested to see what you’ve done.

  • #7 / Mar 07, 2009 2:08pm

    macigniter's avatar

    macigniter

    244 posts

    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:

    ->fieldset(STR legend [, ARR|STR attributes])
    ->hidden(STR name|id [, STR value])
    ->label(STR label, STR for [, ARR|STR attributes])
    ->text(STR name|id [, STR label, STR rules, STR value, ARR|STR attributes])
    ->password(STR name|id [, STR label , STR rules, STR value, ARR|STR attributes])
    ->textarea(STR name|id [, STR label, STR rules, STR value, ARR|STR attributes])
    ->upload(STR name|id [, STR label, BOOL required, ARR|STR attributes])
    ->iupload()
    ->select(STR name|id, ARR options [, STR label, ARR|STR selected, STR rules, ARR|STR attributes])
    ->checkbox(STR name|id, STR value [, STR label, BOOL checked, STR rules, ARR|STR attributes])
    ->checkgroup(STR name, ARR checks [, ARR|STR checked, STR rules, ARR|STR attributes])
    ->radiogroup(STR name, ARR radios [, ARR|STR checked, STR rules, ARR|STR attributes])
    ->button(STR content [, STR name|id, STR type, ARR|STR attributes])
    ->image(STR src [, STR name|id, ARR|STR attributes])
    ->submit([STR value, STR name|id, ARR|STR attributes])
    ->reset([STR value, STR name|id, ARR|STR attributes])
    ->span(STR content [, ARR|STR attributes])
    ->html(STR content)
    ->br()
    ->hr()
    ->space()

    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’ll keep you all posted!

  • #8 / Mar 07, 2009 4:41pm

    brianw1975's avatar

    brianw1975

    257 posts

    any info on doctype?  will it support both html and xhtml? 

    what about the form tag attribs?  name, id, action, enctype, etc?

  • #9 / Mar 07, 2009 5:51pm

    Fero's avatar

    Fero

    54 posts

    I want to see some example of usage 😉

    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:

    ->fieldset(STR legend [, ARR|STR attributes])
    ->hidden(STR name|id [, STR value])
    ->label(STR label, STR for [, ARR|STR attributes])
    ->text(STR name|id [, STR label, STR rules, STR value, ARR|STR attributes])
    ->password(STR name|id [, STR label , STR rules, STR value, ARR|STR attributes])
    ->textarea(STR name|id [, STR label, STR rules, STR value, ARR|STR attributes])
    ->upload(STR name|id [, STR label, BOOL required, ARR|STR attributes])
    ->iupload()
    ->select(STR name|id, ARR options [, STR label, ARR|STR selected, STR rules, ARR|STR attributes])
    ->checkbox(STR name|id, STR value [, STR label, BOOL checked, STR rules, ARR|STR attributes])
    ->checkgroup(STR name, ARR checks [, ARR|STR checked, STR rules, ARR|STR attributes])
    ->radiogroup(STR name, ARR radios [, ARR|STR checked, STR rules, ARR|STR attributes])
    ->button(STR content [, STR name|id, STR type, ARR|STR attributes])
    ->image(STR src [, STR name|id, ARR|STR attributes])
    ->submit([STR value, STR name|id, ARR|STR attributes])
    ->reset([STR value, STR name|id, ARR|STR attributes])
    ->span(STR content [, ARR|STR attributes])
    ->html(STR content)
    ->br()
    ->hr()
    ->space()

    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’ll keep you all posted!

  • #10 / Mar 07, 2009 7:43pm

    phused

    36 posts

    This seems very interesting, looking forward to it.

  • #11 / Mar 08, 2009 12:25am

    drewbee's avatar

    drewbee

    480 posts

    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.

    I really should get crackin on this eh?

  • #12 / Mar 08, 2009 9:41am

    macigniter's avatar

    macigniter

    244 posts

    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
    
    $form = new Form();
    $form
    ->open('action', 'form_name|bob', 'style=width:234px')
    ->text('test', 'Test Input', 'required|callback_validateTest|maxlength[50]', 'Default Value', 'class=field')
    ->select('test2', $select, 'Test Select 2:', 0, 'required|callback_validateTest', 'class=select');
    
    echo $form->get();

    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.

  • #13 / Mar 08, 2009 9:45am

    macigniter's avatar

    macigniter

    244 posts

    any info on doctype?  will it support both html and xhtml? 

    what about the form tag attribs?  name, id, action, enctype, etc?

    The library utilizes CI’s form helpers, so the output code is dependent on that.

    Please see my previous post for the form tag attributes. You can use:

    ->open(STR action [, STR name, STR|ARR attributes])

  • #14 / Mar 23, 2009 4:03am

    Jan_1's avatar

    Jan_1

    129 posts

    I’m a Newbie, therefore it sounds very interesting, looking forward to it. Any help/action wanted?

  • #15 / Mar 23, 2009 11:02am

    Iverson

    153 posts

    $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);

    Couldn’t have said it better myself

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases