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 - 04-22-2012 [eluser]Yednotek[/eluser] [quote author="roomen" date="1335116047"]I am confuse about the code, anyone can help me to explain what is mean? thanks[/quote] Which code do you mean? Please make your question more specific and/or post an example of the code that confuses you. Form Generation Library - El Forum - 04-23-2012 [eluser]Yednotek[/eluser] This library is amazing, should be incorporated into the CI core imho!! It makes configuring+displaying+validating forms a breeze. I'm configuring my forms inside my models now, it's beautiful! Form Generation Library - El Forum - 04-24-2012 [eluser]ckm5[/eluser] Is it possible to loop through an array to create fields? I suspect that this breaks things as adding fields looks like construction of one big object, but perhaps there is an answer.... It sure would make things easier. Thx. ckm5 Form Generation Library - El Forum - 04-24-2012 [eluser]Yednotek[/eluser] Yes it's possible, the method chaining is useful but also optional. Form Generation Library - El Forum - 04-24-2012 [eluser]ckm5[/eluser] [quote author="Yednotek" date="1335291067"]Yes it's possible, the method chaining is useful but also optional.[/quote] Ah, OK, I didn't know that's what it was called. Thx. Form Generation Library - El Forum - 04-24-2012 [eluser]ckm5[/eluser] While I'm asking - does anyone have sample code for Datamapper ORM <-> Form Generation Library? I realize I could spend many hours experimenting to find the answer, but if someone has a snippet handy it would be a big timesaver. Thx. ckm5 Form Generation Library - El Forum - 05-02-2012 [eluser]ci_mohammed[/eluser] is radiogroup work or not ? how can u pass checked value of radiogroup to model ? Form Generation Library - El Forum - 05-02-2012 [eluser]Yednotek[/eluser] [quote author="ckm5" date="1335292044"]While I'm asking - does anyone have sample code for Datamapper ORM <-> Form Generation Library? I realize I could spend many hours experimenting to find the answer, but if someone has a snippet handy it would be a big timesaver. Thx. ckm5[/quote] Don't have any code for you, but ask yourself if you really need an ORM. I was thinking of going that route myself, but the learning curve and added complexity was just not worth it. Using formgenlib (definitely worth it!) and smart coding of your models will get you a long way in most cases. Form Generation Library - El Forum - 05-02-2012 [eluser]ckm5[/eluser] [quote author="Yednotek" date="1335980664"][quote author="ckm5" date="1335292044"]While I'm asking - does anyone have sample code for Datamapper ORM <-> Form Generation Library? I realize I could spend many hours experimenting to find the answer, but if someone has a snippet handy it would be a big timesaver. Thx. ckm5[/quote] Don't have any code for you, but ask yourself if you really need an ORM. I was thinking of going that route myself, but the learning curve and added complexity was just not worth it. Using formgenlib (definitely worth it!) and smart coding of your models will get you a long way in most cases.[/quote] Thanks, I figured it out. It's not that hard, took about two hours to get working - if I had had some examples, could have cut that down to 1/2 hour. If anyone is wondering, here's an example. Quick background - I have all the form data in an array* called $post. The data is contained in three different sub-arrays, the one in the example is $post['customer_attributes'], which is customer data (duh). Using DataMapper ORM, you can just feed your array into your db table object (which in my case is called, confusingly, customer_attributes) and call save. Code: // customer If you want to update something in your table, this is what you might do (note - code wrapped for legibility, it's typically just one line) Code: $customer_attributes The actual model file is just the normal Datamapper model: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); I don't know if this saves a lot of other coding, but having all that work done is basically four lines of code is quite good... It's taken me more time to write this post than doing DB updates, and I'm all about saving time.... If you have any questions, happy to explain. It's really not difficult, but it's easy to over analyse how it works - bottom line, it just works. ckm5 * as an aside, you need to be careful with FGL's get_post() as it breaks multi-dimensional arrays. Don't know if there's a way around it, but forms to multi-dimensional arrays is what I always use.... Form Generation Library - El Forum - 05-10-2012 [eluser]Yednotek[/eluser] Ok I have to admit I was a bit lazy in doing my research It does look elegant but still I don't see much here that you couldn't have done with a few lines of code and using CI's Active Record class for example. From what I saw things get more complicated when you are working with relationships, foreign keys etc. If you have another simple example with relations involved feel free to share In my current project I often have to manage relationships between 5 or 6 tables. As a side note I personally find SQL a bit easier to read than the method chaining: Code: $customer_attributes vs Code: $this->db->query("UPDATE customer_attributes SET uuid=? But I guess that's a matter of taste and getting used to. Thanks for sharing. |