Jump to content

Dynamic Form Fields - customizing your dbase from the website?


Siggles

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.