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-27-2009

[eluser]BaRzO[/eluser]
I did not see any examples of (DMZ + formlib) but both of them has clearly user guide and some examples just play around whit them Wink


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

[eluser]connors[/eluser]
First of all, I just wanna say thanks for this plugin - really eases the form job.

I'm using 0.22 prerelease and I've ran into a few issues - Don't know if it's just me or it really is bugs.
Anyway.. First one is about the model function.

I'm not sure why, but the form isn't calling my model when I'm using form->valid after declaring it:
Code:
CI::library('form')->open('register/user')
/* Loads of fields here */
                       ->submit()
                       ->reset()
                       ->validate()
                       ->model('user','check_register');

if(CI::library('form')->valid)
{
   // Success stuff here
}
No matter where i put the ->model function, it's not called and is instead going to the if ->valid section. Bug or error in my code?

When i comment out the if ->valid part, the model is called - well, tries to - and I'm getting an error that it can't find the 'user' model.
I belive that CI models needs to by suffixed with _model, so I'm guessing this is a bug in the form lib?
Change line 2389 (the model function) from
Code:
$this->model = $model;
to
Code:
$this->model = $model.'_model';

I'm setting an error in my model for debug purposes, and when my model was finaly called it replaced my class with " error" istead of appending it.
It's fixable by modifying line 2110 from
Code:
if ($this->$el->type != 'checkbox' && $this->$el->type != 'radio') $this->$el->atts['class'] = (isset($this->$el->atts['class'])) ? ' '.$this->config['error_class'] : $this->config['error_class'];
to
Code:
if ($this->$el->type != 'checkbox' && $this->$el->type != 'radio') $this->$el->atts['class'] = (isset($this->$el->atts['class'])) ? $this->$el->atts['class'].' '.$this->config['error_class'] : $this->config['error_class'];

Once again, I dont know if you've already fixed them, just wanted to point them out Smile


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

[eluser]groyk[/eluser]
Hi MacIgniter

I can see that you have made this single page user guide. Is it possible to download this in full size?

Further it would be a greate idea to add the download link to your first post in this thread. Just for new "FGL" users.

Kind regards
Groyk

[quote author="macigniter" date="1252681229"]Hi Everyone,

I just completed a quick reference guide for the Form Generation Library since I always forget myself which value goes where in the library's methods. I thought you'd appreciate to have one, too. So I am making it available for everyone. Oh and by the way, did I mention that I love small donations? ;-)

Here it is for download:
Form Generation Library Quick Reference[/quote]


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

[eluser]Sinclair[/eluser]
[quote author="Sinclair" date="1261780508"]Hi,

I need to do CRUD operations with forms. Where can I find an example on how to do it with "Form Generation Library"?

Best Regards,[/quote]

What I'am looking for CodeIgniter is a Class like this one: http://phpclasses.mkdata.net/browse/package/3249.html

There is something similar to this in CodeIgniter?


Best Regards.


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

[eluser]2think[/eluser]
[quote author="connors" date="1261943675"]First of all, I just wanna say thanks for this plugin - really eases the form job.

I'm using 0.22 prerelease and I've ran into a few issues - Don't know if it's just me or it really is bugs.
Anyway.. First one is about the model function.

I'm not sure why, but the form isn't calling my model when I'm using form->valid after declaring it:
Code:
CI::library('form')->open('register/user')
/* Loads of fields here */
                       ->submit()
                       ->reset()
                       ->validate()
                       ->model('user','check_register');

if(CI::library('form')->valid)
{
   // Success stuff here
}
No matter where i put the ->model function, it's not called and is instead going to the if ->valid section. Bug or error in my code?

When i comment out the if ->valid part, the model is called - well, tries to - and I'm getting an error that it can't find the 'user' model.
I belive that CI models needs to by suffixed with _model, so I'm guessing this is a bug in the form lib?
Change line 2389 (the model function) from
Code:
$this->model = $model;
to
Code:
$this->model = $model.'_model';

I'm setting an error in my model for debug purposes, and when my model was finaly called it replaced my class with " error" istead of appending it.
It's fixable by modifying line 2110 from
Code:
if ($this->$el->type != 'checkbox' && $this->$el->type != 'radio') $this->$el->atts['class'] = (isset($this->$el->atts['class'])) ? ' '.$this->config['error_class'] : $this->config['error_class'];
to
Code:
if ($this->$el->type != 'checkbox' && $this->$el->type != 'radio') $this->$el->atts['class'] = (isset($this->$el->atts['class'])) ? $this->$el->atts['class'].' '.$this->config['error_class'] : $this->config['error_class'];

Once again, I dont know if you've already fixed them, just wanted to point them out Smile[/quote]

Connors,
Have you tried the syntax used in the Getting Started section of the user guide? http://frankmichel.de/formgenlib/user_guide/introduction/getting_started.html I understand the CI::library syntax but haven't seen it used before in Codeigniter source code.

You also do NOT need to append _model to Codeigniter classes, this you may have seen only because it is a preference of a particular programmer.


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

[eluser]2think[/eluser]
[quote author="Sinclair" date="1262031294"][quote author="Sinclair" date="1261780508"]Hi,

I need to do CRUD operations with forms. Where can I find an example on how to do it with "Form Generation Library"?

Best Regards,[/quote]

What I'am looking for CodeIgniter is a Class like this one: http://phpclasses.mkdata.net/browse/package/3249.html

There is something similar to this in CodeIgniter?


Best Regards.[/quote]

Hi Sinclair,
Although I have never used the package you linked to, I went through his feature list and will try to answer as best as an amateur like myself can. With the features described in that package, they are all available in Codeigniter. The last feature he listed, the browser neutrality, is perhaps more of a CSS/design issue.

The various libraries, helpers and framework itself provides all that functionality and much more.


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

[eluser]macigniter[/eluser]
[quote author="groyk" date="1261962613"]
I can see that you have made this single page user guide. Is it possible to download this in full size?

Further it would be a greate idea to add the download link to your first post in this thread. Just for new "FGL" users.

Kind regards
Groyk[/quote]

It actually is on the first page of this thread. And I just updated the link id, so it is available for download again...


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

[eluser]Jakebert[/eluser]
[quote author="macigniter" date="1261872907"][quote author="BaRzO" date="1261801900"]
Maybe you can merge formlib and ( DataMapper DMZ )[/quote]

That's what I am doing. Works like a charm. DataMapper and the Form Generation Library work very well together and speed up development time big time. :-)[/quote]

Do you find yourself running form validation twice: once in the model (from DMZ) and once from the form library? Is this redundant? Or "better safe than sorry"?


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

[eluser]macigniter[/eluser]
[quote author="Jakebert" date="1262088381"]
Do you find yourself running form validation twice: once in the model (from DMZ) and once from the form library? Is this redundant? Or "better safe than sorry"?[/quote]

I am not using the form validation of DMZ. Just the ORM functionality. I personally validate the form with FGL. But I guess it works both ways. I wouldn't double-validate for better performance.


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

[eluser]macigniter[/eluser]
It's done! The Form Generation Library version 1.0 is available for download.

Please check out the updated user guide (which is still not complete, but far more completed than before).

Let me know how the new version works out for you...