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 - 12-06-2009

[eluser]BaRzO[/eluser]
how can i use iupload or upload ? pls give a snippet...


Form Generation Library - El Forum - 12-07-2009

[eluser]dinhtrung[/eluser]
@macigniter : Another consideration is to include jQuery validate plugins into Form library! I thought about this lastnight. Although Form_Validation and File_Upload class in CI is quite good, it will take extra routine to validate the data across client and server. I just think about add some jQuery magic into Form Gen too.
Also, when implement the populate($data) function, I see the $form->set_value() can only set value for text, password and hidden fields, not for checkbox, radio and select. I changed:
Code:
function set_value($name = '', $value = '')
    {
        if ($this->_last_accessed && !$value) {
            if (!$name) show_error(FGL_ERR . 'set_value: No value specified');
            $value = $name;
            $el = $this->_last_accessed;
        } else {
            if (!$name) show_error(FGL_ERR . 'set_value: No element name specified');
            if (!$value) show_error(FGL_ERR . 'set_value: No value specified');
            $el = $this->_el_get_unique($name);
        }
        if ($el) {
            switch ($this->$el->atts['type']){
                case 'select':
                    $this->$el->selected = $this->_make_array($value);
                    break;

                case 'checkbox':
                case 'radio':
                    $this->$el->atts['checked'] = (in_array($this->$el->atts['value'], $this->_make_array($value))) ? TRUE : FALSE;
                    break;

                case 'submit':
                case 'reset':
                    $this->$el->atts['value'] = $value;
                    break;

                case 'password':
                    $this->$el->atts['value'] = '';
                    break;

                default:
                    $this->$el->atts['value'] = $value;
                    break;
            }            
        }



Form Generation Library - El Forum - 12-07-2009

[eluser]Boris Strahija[/eluser]
I have to say again the library is awsome. I've alredy used it on a couple project without any problems. Soon it's gonna be used on the slovenian Cesar and Sheeba sites Wink

Integration with the jQuery validation plugin would be very nice. It would eliminate 1 step for my every form, since I'm using the plugin everywhere.


Form Generation Library - El Forum - 12-07-2009

[eluser]macigniter[/eluser]
[quote author="dinhtrung" date="1260221665"]@macigniter : Another consideration is to include jQuery validate plugins into Form library![/quote]

Although I personally use jQuery and love it I don't want to add anything more besides reCaptcha that makes users force to use any tool or script. I'm sure there's tons of people out there that use other JavaScript frameworks and you simply cannot respect everybody's preferences.

I'm sure that the Form Generation Library gives developers enough to work with and implement JS validation easily without any core modifications to the library.


Form Generation Library - El Forum - 12-07-2009

[eluser]macigniter[/eluser]
[quote author="Boris Strahija" date="1260221826"]I have to say again the library is awsome. I've alredy used it on a couple project without any problems. Soon it's gonna be used on the slovenian Cesar and Sheeba sites Wink

Integration with the jQuery validation plugin would be very nice. It would eliminate 1 step for my every form, since I'm using the plugin everywhere.[/quote]

I like to hear that you have succesfully implemented the library into your commercial projects. Have you considered giving back by buying the author a beer? ;-)

About the jQuery plugin... I'll think about it...


Form Generation Library - El Forum - 12-07-2009

[eluser]macigniter[/eluser]
@everyone

Guys, lots of you are using the library for a while now and since I am terribly busy I would love you to help me out in completing the user guide. Please feel free to create the missing pages as good as you can and send them to my private email address [info at frankmichel dot com]. You can download the template here.

Please please please help me to finally finish the user guide so everyone can take good use of it!!


Form Generation Library - El Forum - 12-07-2009

[eluser]Boris Strahija[/eluser]
[quote author="macigniter" date="1260222267"][quote author="Boris Strahija" date="1260221826"]I have to say again the library is awsome. I've alredy used it on a couple project without any problems. Soon it's gonna be used on the slovenian Cesar and Sheeba sites Wink

Integration with the jQuery validation plugin would be very nice. It would eliminate 1 step for my every form, since I'm using the plugin everywhere.[/quote]

I like to hear that you have succesfully implemented the library into your commercial projects. Have you considered giving back by buying the author a beer? ;-)

About the jQuery plugin... I'll think about it...[/quote]
I will definitely donate a couple of bucks, possibly for a whole case of beer Wink


Form Generation Library - El Forum - 12-07-2009

[eluser]macigniter[/eluser]
[quote author="dinhtrung" date="1260221665"]I see the $form->set_value() can only set value for text, password and hidden fields, not for checkbox, radio and select.[/quote]

Thanks for noticing. It'll be changed with the next version. I have implemented all changes now and am testing the new features before I'll release the new version along with the change notes.

Again I would LOOOOOOOOVE if someone would help me with the user guide :-)


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

[eluser]dinhtrung[/eluser]
@macigniter: Sorry, but my writing is not good enough to help you with the user guide.
I add populate() function to help fill in the data automatically. This is very useful in modify() function in CRUD based controller.
Code:
function populate($values)
    {
        if (is_array($values))
            foreach($values as $el => $value) {
                if ($value && ! empty($this->$el)) {
                    switch ($this->$el->atts['type']){
                        case 'select':
                            $this->$el->selected = $this->_make_array($value);
                            break;
        
                        case 'checkbox':
                        case 'radio':
                            $this->$el->atts['checked'] = (in_array($this->$el->atts['value'], $this->_make_array($value))) ? TRUE : FALSE;
                            break;
        
                        case 'submit':
                        case 'reset':
                            $this->$el->atts['value'] = $value;
                            break;
        
                        case 'password':
                            $this->$el->atts['value'] = '';
                            break;
        
                        default:
                            $this->$el->atts['value'] = $value;
                            break;          
                    }            
                }
            }
        return $this;
    }
Don't know why I can't use set_value() above. It fill in all the select, check and radio, but not for password, textarea or text. Maybe set_value is only used for those elements?


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

[eluser]Mat-Moo[/eluser]
[quote author="macigniter" date="1260222925"][quote author="dinhtrung" date="1260221665"]I see the $form->set_value() can only set value for text, password and hidden fields, not for checkbox, radio and select.[/quote]

Thanks for noticing. It'll be changed with the next version. I have implemented all changes now and am testing the new features before I'll release the new version along with the change notes.

Again I would LOOOOOOOOVE if someone would help me with the user guide :-)[/quote]

What bit do you need help with? I'm really behind with some stuff at the moment but would love to help back as a donation.