Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a "dynamic" forms - and store data and form design in two fields

I am making a system for at company that has a lot of field workers that need to fill out a lot of certificates at every job they do. We do this via a tablet pc running a mysql/php/apache system that syncs to the main server.

These certificates change a lot - so I get newer revisions all the time. And if I make this in a traditional database/php/html setup - I would be changing designs and databases forever, not to talk about handling revisions of certificate designs and data. (adding, removing fields)

I am looking for a way where I easily can design a form and store its design and data in one row (in two fields) - in my mysql database. So that when reading a specific row - I always have the correct design matched to its data I can merge together. This can be done via xforms - but the browser needs a plugin to do this. An xforms is tedious.

It is fairly easy to do with text fields only, but I need checkboxes, lists and so on....

Any brainstorming is appreciated.

like image 205
Anders Avatar asked Feb 09 '11 11:02

Anders


2 Answers

What about using a NoSQL like MongoDB for storing the certifacates? Would that work for you?

like image 199
Thomas Jensen Avatar answered Sep 29 '22 00:09

Thomas Jensen


If I understand right you are especially looking for a way to save the user data to a database, as mentioned before you can change your your database engine to a NoSQL dbe or export the data to CSV, JSON, or use the php serialize() function.

If you want to have real fieldnames you can use multiple tables for storing the data. The main table only has the type of the certificate and the id of the real data in another table saving the data for a specific certificate (and maybe some general data, e.g. a timestamp).

This method isn't perfect and requires more PHP code and fetching similar data from multiple tables but it is the method I'd prefer.

like image 21
Seoester Avatar answered Sep 28 '22 23:09

Seoester