Page 1 of 1
Best place for forms
Posted: Thu Jan 31, 2008 12:02 am
by jeffrydell
I'm building a multi-page "interview wizard" application. There are conditional branches, loops, and step skipping built in to the logic. Most of that logic is mapped in a MySQL table. Also in the table is a text field which contains context-sensitive (html formatted) 'Help' screens which get loaded into a variable each time the user reaches the next step.
The Help Screen concept got me to thinking ... what about putting each step's FORM code in another text field?
Please let me know your thoughts about keeping the html for a form in a text field versus keeping the html for the form in a file on the server. Pro's & con's Please!
Thanks!
Re: Best place for forms
Posted: Thu Jan 31, 2008 2:51 pm
by SpecialK
I have done this for a managers request. His thinking was then you can easily do a search on all the data on the site.
It may help when doing a generic template.
I would think the biggest downside is you have to query the database on every request there. I don't know numbers but I think a database query is slower then a file access, especially if it's a static file.
Re: Best place for forms
Posted: Thu Jan 31, 2008 3:00 pm
by jeffrydell
Good thoughts - thanks! I'm already querying the db for that record as a part of taking the next step in the application, so maybe I'm saving time because I'm not doing that query AND loading the file after the query (which would contain the name of the file location in one of the fields).
Instead I'm just spankin' the code right in to a var ... and accessing memory is ALWAYS faster than disc access.
Re: Best place for forms
Posted: Thu Jan 31, 2008 4:42 pm
by Christopher
I don't think it really matters and is just an implementation detail. Typically they are included from files because it is easy, but if you are already fetching the record then including the HTML in the record makes sense. This is what many CMSs do.
I would recommend making the thing datasource independent. Put the fetching code inside a Model object an then you can switch from files to database without modifying the app.
Re: Best place for forms
Posted: Thu Jan 31, 2008 5:09 pm
by alex.barylski
I'd personally keep HTML form code in a file, just because it's easier to edit in a IDE as opposed to using the TEXTAREA in phpMyAdmin or other. You could build in a WYSIWYG which updated your FORM code I suppose, but most make a total mess of FORM's.
While I do store HTML content in databases, I keep everything else as native files for maximum portability and reuse.