CodeIgniter Forums
Form Generation Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Form Generation Library (/showthread.php?tid=16439)



Form Generation Library - El Forum - 08-25-2009

[eluser]Boris Strahija[/eluser]
Great library, but there's one thing that bothers me a little. When I try to add a button element with the type submit, it automaticly changes it to a input element. I don' like that, and I think there should be a way to add a submit <button>. I'm doing it now with the html() method.


Form Generation Library - El Forum - 08-25-2009

[eluser]macigniter[/eluser]
[quote author="Boris Strahija" date="1251227362"]Great library, but there's one thing that bothers me a little. When I try to add a button element with the type submit, it automaticly changes it to a input element. I don' like that, and I think there should be a way to add a submit <button>. I'm doing it now with the html() method.[/quote]

Thanks for pointing this out. I will overhaul the ->button() method and update it with the next version.


Form Generation Library - El Forum - 08-25-2009

[eluser]macigniter[/eluser]
[quote author="Jeffrey Lasut" date="1251227079"]
I'm testing your library and currently you can only call a model and model method, is there a way to call a library and his method's?[/quote]

Why would you want to load a library from within the form generation code?


Form Generation Library - El Forum - 08-25-2009

[eluser]Jeffrey Lasut[/eluser]
[quote author="macigniter" date="1251229390"]
Why would you want to load a library from within the form generation code?[/quote]

The auth library I'm using is Tank Auth, and de method checking de login password and hash against the database is located in the library, the models are only used to update, insert and delete the information from the database.
Within the library method I would like to use the form generation validation:

Code:
$form->add_error('password', 'You entered a bad password.');

Any suggestions or other solutions?

jeffrey


Form Generation Library - El Forum - 08-25-2009

[eluser]macigniter[/eluser]
@jeffrey

I am not familiar with Tank Auth, but how would you check the login and passwort without the form generation library?


Form Generation Library - El Forum - 08-27-2009

[eluser]macigniter[/eluser]
[quote author="12vunion" date="1250724175"]I'm new to the form generator so I don't know every single thing to account for, but this is basically working. Please test it more thoroughly than I have and I'd love to see it worked into the next version. Thanks for the cool library. Smile

Here, put this in your Form to get this running (I put it on line 1390).
Code:
/**
     * Get Post
     *
     * Returns the submitted form post values as array
     */
    function get_post()
    {
        $post_values = array();
        foreach ($this->_elements as $el)
        {
            if ($el['name']){
                $name = str_replace("[]", "", $el['name']);
                $value = $this->CI->input->post($name, true);
                //fix for the annoying way selects, checkboxes and radios work
                if( is_array($value) && count($value) == 1){
                    $value = $value[0];
                }
                
                $post_values[ $name ] = $value;
            }
            
        }
        
        return $post_values;
    }
[/quote]

This was added to the next version and your credits are now in the user guide :-)
Next version will be available anytime soon...


Form Generation Library - El Forum - 08-27-2009

[eluser]macigniter[/eluser]
NEW version is available now for download. Check out the changes:

[0.2.0]
- added get_post() method to retrieve validated and xss_cleaned post data
- changed button() method when used as 'submit' or 'image' type (now creates <button> instead of &lt;input&gtWink
- improved stylesheet style.css (e.g. vertical alignment of checkboxes)
- improved source code to validate XHTML 1.0 Transitional when reCAPTCHA is being used

I can't believe how great this library develops and I am glad you guys all like it!! If anyone of you is using the library for a while now and feels confident enough to help me finishing the user guide (especially by adding all the methods) I would REALLY be happy and add your name to the credits ;-) Seriously, if you want to help with the user guide, just download the full version and edit the missing pages. You can send them to me at info[at]frankmichel[dot]com.

Happy form generating!


Form Generation Library - El Forum - 08-30-2009

[eluser]Unknown[/eluser]
Hi,

first of all congratz with this incredible library. It's a real timesaver.

By playing around with this lib and joining it with TinyMCE textarea's I encountered a little bug, situated right here (line 1563):
Code:
if ($type != 'checkbox' && $type != 'radio') $this->$element->atts['class'] = (isset($this->$element->atts['class'])) ? ' '.$this->config['error_class'] : $this->config['error_class'];

It just overwrites the whole class of the element (in terms of the TinyMCE story: removing the whole TinyMCE layout), even if it shouldn't be replaced.
So, I corrected the code to the following:
Code:
if ($type != 'checkbox' && $type != 'radio') $this->$element->atts['class'] = (isset($this->$element->atts['class'])) ? $this->$element->atts['class'].' '.$this->config['error_class'] : $this->config['error_class'];

Works like a charm now Wink


Form Generation Library - El Forum - 08-30-2009

[eluser]macigniter[/eluser]
Thanks for pointing out the bug! I will fix it for the next release!


Form Generation Library - El Forum - 09-02-2009

[eluser]seanloving[/eluser]
Here's a segment of my code

Code:
->text('zipcode', 'from', 'max_length[5]', '-- zipcode --')

that generates the following HTML

Code:
<label for="zipcode" class="left">from</label>&lt;input type="text" name="zipcode" value="zipcode" o_nkeypress="this.style.borderColor='#666'" maxlength="5" id="zipcode" style="margin-left:10px"  /&gt;&lt;br />

1. where does the onkeypress come from?

2. why do I have to add the underscore in the o_nkeypress so that it will properly display in the forum !!?? Is this a bug in the forum?

3. how do I change the size= parameter of the text box?

thanks