Welcome Guest, Not a member yet? Register   Sign In
Form Generation Library
#11

[eluser]drewbee[/eluser]
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:

Code:
$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

[eluser]macigniter[/eluser]
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).

Code:
$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

[eluser]macigniter[/eluser]
[quote author="brianw1975" date="1236480063"]any info on doctype? will it support both html and xhtml?

what about the form tag attribs? name, id, action, enctype, etc?[/quote]

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

[eluser]Jan_1[/eluser]
I'm a Newbie, therefore it sounds very interesting, looking forward to it. Any help/action wanted?
#15

[eluser]Iverson[/eluser]
Code:
$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
#16

[eluser]macigniter[/eluser]
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.

You can see a working demo of the library by visiting this page:
Form Generation Library Examples

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.
#17

[eluser]quasiperfect[/eluser]
this will be really nice to test out
#18

[eluser]macigniter[/eluser]
[quote author="Jan from Hamburg" date="1237809825"]I'm a Newbie, therefore it sounds very interesting, looking forward to it. Any help/action wanted?[/quote]

Hi Jan, as soon as the library will be available for download I am happy about any feedback and code improvement I can get. I am not a high-end professional programmer, so I'm sure there will be lots of stuff to clean-up or improve. I hope that everybody who uses it will send me their inputs and improvements which I will then incorporate in future versions.
#19

[eluser]got 2 doodle[/eluser]
sounds like an excellent addition, I can't wait.

doodle
#20

[eluser]abmcr[/eluser]
Any news? Thank you




Theme © iAndrew 2016 - Forum software by © MyBB