Siggles Posted February 6, 2009 Share Posted February 6, 2009 Hi, I am creating a directory of contacts and details for the company I work for using a mixture of PHP and MySQL. I was halfway through creating a database and adding fields such as 'fax number' when I thought, 'What if the boss asks me to add a field later down the line?' There must be some way to allow someone non compitent in web design / mysql etc to do this with an admin page on the site. It got me thinking that it would make sense to create a table in MySQL just for the fields or form fields themselves and then somehow link the data for thos fields from another table. But you would need more fields in that first table (for example), field_name = (eg, Address), field_visibility = (if it is created but you wish to hide it), field_order = (what order it is listed in the form online, name first, address second, etc). To cut to the chase, is this a simple thing to do? Does anybody have a good example where this is in use? How would I add form fields that need radio buttons or that only allow e-mail addresses or that are max 20 characters etc etc. How will I show them dynamically on the page? Any help would be greatly appreciated. Regards Siggles Quote Link to comment https://forums.phpfreaks.com/topic/144085-dynamic-form-fields-customizing-your-dbase-from-the-website/ Share on other sites More sharing options...
JonnoTheDev Posted February 6, 2009 Share Posted February 6, 2009 Not simple at all. Think of the validation routines. Lets say you have a scenario where you want 4 checkboxes in the form and at least 2 of them must be checked. How could you validate this dynamically. Also with a select list you may need to display different fields based on the selection i.e country. This maybe a requirement. For the time it takes to add form fields, validation and database table fields I wouldn't bother trying to make it dynamic. What I would do though is create an OO interface for my forms so you can add extra fields easily of any type and specify the type of validation required on the entry. Quote Link to comment https://forums.phpfreaks.com/topic/144085-dynamic-form-fields-customizing-your-dbase-from-the-website/#findComment-756083 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.