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

[eluser]macigniter[/eluser]
Last Saturday my MacBook Pro crashed and I had to go through some serious data recovery nightmare. Fortunately all my data is restored and can continue working on this. I am in the state of cleaning up the code now and commenting it. After that I will publish the first version. Sorry it took longer than expected, but I added more functionality and had some unexpected obstacles on the way.

Thanks for being patient...
#22

[eluser]got 2 doodle[/eluser]
Sounds familiar, I just had to rebuild my XP laptop and out of sheer frustration, I have just set up a Ubuntu box.

I hope to keep the XP for general computer tasks, emails etc.

The Ubuntu box will be my development platform, I got tired of the Windows/Linux problems that I would run into when deploying a site. Permissions, case sensitive stuff.

Ubuntu is cool :coolsmile: still trying out the best editor (komodo is looking good) etc.

It was very easy to setup as a server, goodbye xampp!

Looking forward to your library

doodle
#23

[eluser]dinhtrung[/eluser]
I am writing a little php page to help generate forms from a csv file.
The csv file can have fields like "type, name, default" etc etc etc. The output form is compatible with CI's Form validation library, and the layout is based on blueprintcss.org 's Form layout.
IMHO, it's easier to generate a form view, put it in views folder and load it later, rather than write the form directly within controller.
The code is simple:
Code:
function index() {
            $errors = array();            
            $userfile['upload_path'] = '/tmp/';
            $userfile['allowed_types'] = 'csv';
            $userfile['overwrite'] = TRUE;
            $userfile['remove_spaces'] = TRUE;
            $this->upload->initialize($userfile);
            if ($this->upload->do_upload('userfile')) {
                $fileinfo['userfile'] = $this->upload->data();
            } else {
                $errors['userfile'] = $this->upload->display_errors();
            }
            
            if (count($errors) == 0) {
                echo "<h1>Result source code</h1>\n";
                $handle = fopen($fileinfo['userfile']['full_path'], 'r');
                $fields = array('label','info','type','name','value');
                $out = "";                
                while (($data = fgetcsv($handle, 4096)) != FALSE) {
                    $tmp = array_combine($fields, $data);
                    extract($tmp);
                    $out .= "<p><label for='$name'>".(($info)?"<abbr title='$info'>$label</abbr>":$label)."</label><br/>\n";                                                        
                    $out .= "&lt;input id='$name' type='$type' name='$name' value='&lt;?= set_value('$name', \$$name); ?&gt;' /&gt;&lt;/p>\n";
                    $out .= "\n";
                }
                fclose($handle);
                echo "<pre>\n".htmlentities($out)."</pre>";                                
            } else {
                echo "<h2>CodeIgniter Form Generator</h2>\n";
                echo "&lt;form action='".current_url()."' method='post' enctype='multipart/form-data'&gt;\n";                
                echo "&lt;input type='file' name='userfile'/&gt;\n";
                echo "&lt;input type='submit' value='Generate Form' /&gt;\n";
                echo "&lt;/form&gt;";
            }
        }

Right after the "extract($tmp)" line, you could handle the output based on type column, default values, etc etc etc... With this, I could use OpenOffice Calc to export csv and then upload it to localhost ci to generate the form I need in no time.
Cheers
#24

[eluser]eveiga[/eluser]
sooooooo? Smile

Just needing something like this! I'll stay tunned

Cheers
#25

[eluser]macigniter[/eluser]
I have worked all day on creating more pages for the User Guide. I really don't want to publish the script without the complete User Guide being up and running, since I am sure otherwise there will be lots of questions on how to use the library. The User Guide is about 50% done now.
#26

[eluser]got 2 doodle[/eluser]
Quote:otherwise there will be lots of questions on how to use the library

++that

Documentation will be key!

doodle
#27

[eluser]Kyle Johnson[/eluser]
I'm very excited to see someone putting together a very well thought out Form library. I have been working on one for a little while, but I have only been working with PHP for about 5 months now, so it's all very new to me.

I was looking at the user_guide and found an error in the Select generation that makes it not XHTML validated.

I hardly use optgroups, but I'd like to help as much as I can.

Code:
<label for="multi">Multiple Select</label>
<select name="single" id="multi" multiple="multiple" style="height:150px">
<optgroup>Group X</optgroup>
   <option value="1">One</option>
   <option value="2" selected="selected">Two</option>
   <option value="3">Three</option>
<optgroup>Group Y</optgroup>
   <option value="4">Four</option>
   <option value="5" selected="selected">Five</option>
</select>

W3C shows proper like this.
Code:
<label for="multi">Multiple Select</label>
<select name="single" id="multi" multiple="multiple" style="height:150px">
<optgroup label="Group X">
   <option value="1">One</option>
   <option value="2" selected="selected">Two</option>
   <option value="3">Three</option>
</optgroup>
<optgroup label="Group Y">
   <option value="4">Four</option>
   <option value="5" selected="selected">Five</option>
</optgroup>
</select>
#28

[eluser]macigniter[/eluser]
thanks for letting me know, kyle. it's actually just a flaw in the user guide. the code output is xthml conform. please check out http://www.frankmichel.com/formgenlib/examples/right and click the validation button. i will update the user guide accordingly.
#29

[eluser]Kyle Johnson[/eluser]
[quote author="macigniter" date="1238799212"]thanks for letting me know, kyle. it's actually just a flaw in the user guide. the code output is xthml conform. please check out http://www.frankmichel.com/formgenlib/examples/right and click the validation button. i will update the user guide accordingly.[/quote]

Sweet! Well I'm glad it was just a typo.

Thanks again for taking the time to make a library like this. I'm hoping that it will eventually make it into the base libraries included with CodeIgniter.
#30

[eluser]codex[/eluser]
Dude, I can't wait for you to release this plugin. I really despise making forms :coolsmirk:




Theme © iAndrew 2016 - Forum software by © MyBB