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 - 11-24-2009 [eluser]dinhtrung[/eluser] I tried to build a login form with Tank Auth and Form Generation, but Form validation keep complain Code: add_error: Element name "username" does not exist Code: $this->form->open($this->uri->uri_string()) Code: function login(&$form, $data) Form Generation Library - El Forum - 11-25-2009 [eluser]hugle[/eluser] [quote author="dinhtrung" date="1259139436"]I tried to build a login form with Tank Auth and Form Generation, but Form validation keep complain Code: add_error: Element name "username" does not exist Code: $this->form->open($this->uri->uri_string()) Code: function login(&$form, $data) Hello It's strange, your Form setup looks good. I can't see why it can be related with Tank Auth. Maybe this appeared after all your modifications/patches to form library? Maybe you should try not modified version? and a little info about model.. the $data returns not the validated data, but $_POST, author have already fixed this, and soon will be releasing new version of this great lib. As a temp sullution I made this: added function to model: Code: function _process_data($form) and later, instead of $data, I use for example: Code: function support(&$form, $data) Form Generation Library - El Forum - 11-25-2009 [eluser]dinhtrung[/eluser] Quote:Maybe you should try not modified version?Yep, tried with the un-modified version right after seeing the error message. It still there. I tried print_r($this), but it keep print out the structure of Tank_Auth object, not Form library. Maybe it is the cause. Anyway, I worked around this issue by using validate(), not model(). Quote:the $data returns not the validated data, but $_POST, author have already fixed this, and soon will be releasing new version of this great lib.Yeah, waiting for the new version one. I'll try to integrate some more special types of fields. As I usually have to generate time-based report, I think of a form element with jQuery clockpick.js and jQuery-UI datepicker. Another regularly used element is CKeditor or TinyMCE. But it won't be only PHP anymore. Don't know if these kind of element should be add into the library or not. I used to write alot of form elements in pure HTML and <?php echo ?> statement in my views... and now really tired of this similar tasks... Really, Form Generation helps me alot. Form Generation Library - El Forum - 11-25-2009 [eluser]hugle[/eluser] [quote author="dinhtrung" date="1259183816"] Quote:Maybe you should try not modified version?Yep, tried with the un-modified version right after seeing the error message. It still there. I tried print_r($this), but it keep print out the structure of Tank_Auth object, not Form library. Maybe it is the cause. Anyway, I worked around this issue by using validate(), not model(). Quote:the $data returns not the validated data, but $_POST, author have already fixed this, and soon will be releasing new version of this great lib.Yeah, waiting for the new version one. I'll try to integrate some more special types of fields. As I usually have to generate time-based report, I think of a form element with jQuery clockpick.js and jQuery-UI datepicker. Another regularly used element is CKeditor or TinyMCE. But it won't be only PHP anymore. Don't know if these kind of element should be add into the library or not. I used to write alot of form elements in pure HTML and <?php echo ?> statement in my views... and now really tired of this similar tasks... Really, Form Generation helps me alot.[/quote] Well, models are a bit buggy in this version, I have also switched to VALIDATE(); this library AMAZINGLY descreases the code need to be written etc etc. with this lib with 5 lines of code you do all logic - superior. Well, this lib from start seems very nice, so I think such clockpick.js and datepickers would appear in this lib soon. Maybe it would be even better to add smth: config['enable_javasript_validation'] = TRUE; And it would generate jQuery validation rules - seems perfect to me But as for now we must exclude all of other bugs p.s. also using TankAuth here)) Form Generation Library - El Forum - 11-26-2009 [eluser]Mat-Moo[/eluser] Is there an easy way to add wrappers around ->text ->password etc.? I need to get the format Code: <div><label>sss</label><input blah></div> Form Generation Library - El Forum - 11-26-2009 [eluser]hugle[/eluser] Hello It is quite simple, imho If I understood you right, you can try: Code: $this->form->open('/upload/test') Form Generation Library - El Forum - 11-26-2009 [eluser]Mat-Moo[/eluser] I need it around each entity e.g. Code: ->html('<div>'); Form Generation Library - El Forum - 11-26-2009 [eluser]hugle[/eluser] well... maybe I then would do for example: str_replace('<label>', '<div><label>'); then would fix somehow 1st and last matches.. it would do the trick I think Form Generation Library - El Forum - 11-26-2009 [eluser]dinhtrung[/eluser] [quote author="hugle" date="1259298926"]well... maybe I then would do for example: str_replace('<label>', '<div><label>'); then would fix somehow 1st and last matches.. it would do the trick I think [/quote] That's why I modified Form Generation for support various form structure. Look for my patch in this thread. Then in config/form.php, add following config variables: Code: $config['label_prefix'] = "<div>\n"; $label_prefix.form_label().$label_suffix.$input_prefix.form_input().$input_suffix I also add $config['fieldset_open'] and $config['fieldset_close'] in case you use ol, ul and li as form element separator. Example: Code: $config['label_prefix'] = "<li>\n"; Code: <fieldset><ul> Form Generation Library - El Forum - 11-27-2009 [eluser]hugle[/eluser] [quote author="dinhtrung" date="1259319902"][quote author="hugle" date="1259298926"] That's why I modified Form Generation for support various form structure. Look for my patch in this thread. Then in config/form.php, add following config variables: Code: $config['label_prefix'] = "<div>\n"; I really like your patch, but haven't tried it yet just wanna author to release the patched version with all our thoughts Btw, maybe you have already patch for smth like this: for example, I want my output look like: <label>Username:</label> <-- it's with ":" so I basicaly set label to have an ":" - Code: ->text('username', 'Username:', 'trim|xss_clean|required|unique[users.username]'); But when I get errors, I don't want the ":" to appear... Basically now I play with str_replace, But maybe there is already more elegant sollution? Thanks |