Part of the EllisLab Network
   
3 of 71
3
Form Generation Library
Posted: 02 April 2009 12:25 PM   [ Ignore ]   [ # 21 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  187
Joined  01-29-2008

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 cool smile 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

 Signature 

Shameless example of self promotion

Profile
 
 
Posted: 02 April 2009 01:05 PM   [ Ignore ]   [ # 22 ]  
Grad Student
Avatar
Rank
Total Posts:  74
Joined  11-16-2008

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:

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($handle4096)) != FALSE{
                    $tmp 
array_combine($fields$data);
                    
extract($tmp);
                    
$out .= "<p><label for='$name'>".(($info)?"<abbr title='$info'>$label</abbr>":$label)."</label><br/>\n";                                                        
                    
$out .= "<input id='$name' type='$type' name='$name' value='<?= set_value('$name', \$$name); ?>' /></p>\n";
                    
$out .= "\n";
                
}
                fclose
($handle);
                echo 
"<pre>\n".htmlentities($out)."</pre>";                                
            
else {
                
echo "<h2>CodeIgniter Form Generator</h2>\n";
                echo 
"<form action='".current_url()."' method='post' enctype='multipart/form-data'>\n";                
                echo 
"<input type='file' name='userfile'/>\n";
                echo 
"<input type='submit' value='Generate Form' />\n";
                echo 
"</form>";
            
}
        } 

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

Profile
 
 
Posted: 02 April 2009 08:24 PM   [ Ignore ]   [ # 23 ]  
Summer Student
Total Posts:  5
Joined  03-16-2009

sooooooo? smile

Just needing something like this! I’ll stay tunned

Cheers

Profile
 
 
Posted: 02 April 2009 08:27 PM   [ Ignore ]   [ # 24 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  253
Joined  06-23-2008

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.

 Signature 

Tired of forms? Check out Form Generation Library

Profile
 
 
Posted: 03 April 2009 08:36 AM   [ Ignore ]   [ # 25 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  187
Joined  01-29-2008

otherwise there will be lots of questions on how to use the library

++that

Documentation will be key!

doodle

 Signature 

Shameless example of self promotion

Profile
 
 
Posted: 03 April 2009 01:23 PM   [ Ignore ]   [ # 26 ]  
Grad Student
Avatar
Rank
Total Posts:  100
Joined  03-24-2009

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.

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

<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
 Signature 

View my Flickr Account!

Profile
 
 
Posted: 03 April 2009 01:53 PM   [ Ignore ]   [ # 27 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  253
Joined  06-23-2008

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.

 Signature 

Tired of forms? Check out Form Generation Library

Profile
 
 
Posted: 03 April 2009 02:07 PM   [ Ignore ]   [ # 28 ]  
Grad Student
Avatar
Rank
Total Posts:  100
Joined  03-24-2009
macigniter - 03 April 2009 05:53 PM

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.

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.

 Signature 

View my Flickr Account!

Profile
 
 
Posted: 04 April 2009 06:47 AM   [ Ignore ]   [ # 29 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  441
Joined  08-12-2007

Dude, I can’t wait for you to release this plugin. I really despise making forms cool smirk

Profile
 
 
Posted: 07 April 2009 11:46 AM   [ Ignore ]   [ # 30 ]  
Grad Student
Rank
Total Posts:  55
Joined  01-19-2009

Very much looking forward to this. Form validation is a huge time sink, it’d be lovely to have it in one system.

Profile
 
 
   
3 of 71
3