C
C
c5c52016-03-07 09:47:32
PHP
c5c5, 2016-03-07 09:47:32

Give me an idea for storing fields in a database?

There is a form builder. A field in the form can be of the type test, drop-down list (different values), radio (different radio options) + an indication of the number of fields.
Question: how to store all this business universally in the database? Those. some user can create a form of 10 text fields, some of the three drop-down lists and two radios.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Velichko, 2016-03-07
@c5c5

1. Data can be serialized
2. Stored in an intermediate version as text. JSON works well for this.

// checkbox
{
  "type": "checkbox",
  "name": "checkbox-name",
  "id": "checkbox-1",
  "checked": true
}

// select
{
  "type": "select",
  "name": "select-name",
  "id": "select-1",
  "options": [
    {
      "value": 0,
      "label": "Option 1"
    },
    {
      "value": 1,
      "label": "Option 2"
    }
  ]
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question