CodeIgniter Forums
Architecture: Where to Put Forms? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Architecture: Where to Put Forms? (/showthread.php?tid=23058)



Architecture: Where to Put Forms? - El Forum - 09-29-2009

[eluser]fireproofsocks[/eluser]
This is an architecture question: where do you put the code that makes your forms? I'm always a big fan of leaving as much open to the front-end designers as possible, but forms are areas where the MVC architecture gets blurry. I'm wondering how others handle forms in their code... do you guys create a separate library-type file that you can use with different controllers? Or do you put the form code in a view? Just curious...


Architecture: Where to Put Forms? - El Forum - 09-29-2009

[eluser]bigtony[/eluser]
Forms are things that people view, so the "View" seems like a logical place to define the html for them within the MVC architecture.


Architecture: Where to Put Forms? - El Forum - 09-29-2009

[eluser]Johan André[/eluser]
Is there any other way than a view file?
Echoing from the controller/library is out the question.

I design one form for each function (usually that's one database table / form too).
I then use it for both my add and edit-view.


Architecture: Where to Put Forms? - El Forum - 09-29-2009

[eluser]boony[/eluser]
[quote author="Johan André" date="1254232184"]Is there any other way than a view file?
Echoing from the controller/library is out the question.

I design one form for each function (usually that's one database table / form too).
I then use it for both my add and edit-view.[/quote]

Hi,

for what it's worth (2c I think) I also do much the same. I generally have a model for each table and a controller for each model. Forms are used to CRUD the table and are used for the view. So I keep all forms in a sub-directory in the view directory.

Not sure if I'm making myself clear but hey it works for me.