I am going to build a form customize system with Laravel 5.1 LTS. The user could create forms, customize its fields and styles, release them then the other users could fill the form.
In the front-end side, I'm going to use Alpaca Forms. With this package, fields and data are rendered with JSON.
Now the problem is how can I store fields' JSON and data' JSON to MySQL?(I don't really want to use MongoDB or other NoSQL databases, cause I'm already using MySQL now and I don't know how to deal with NoSQL.) The JSON is like this:
$("#form").alpaca({
    "data": {
        "name": "Diego Maradona",
        "feedback": "Very impressive.",
        "ranking": "excellent"
    },
    "schema": {
        "title":"User Feedback",
        "description":"What do you think about Alpaca?",
        "type":"object",
        "properties": {
            "name": {
                "type":"string",
                "title":"Name",
                "required":true
            },
            "feedback": {
                "type":"string",
                "title":"Feedback"
            },
            "ranking": {
                "type":"string",
                "title":"Ranking",
                "enum":['excellent','ok','so so'],
                "required":true
            }
        }
    },
    "options": {
        "form":{
            "attributes":{
                "action":"http://httpbin.org/post",
                "method":"post"
            },
            "buttons":{
                "submit":{}
            }
        },
        "helper": "Tell us what you think about Alpaca!",
        "fields": {
            "name": {
                "size": 20,
                "helper": "Please enter your name."
            },
            "feedback" : {
                "type": "textarea",
                "name": "your_feedback",
                "rows": 5,
                "cols": 40,
                "helper": "Please enter your feedback."
            },
            "ranking": {
                "type": "select",
                "helper": "Select your ranking.",
                "optionLabels": ["Awesome!",
                    "It's Ok",
                    "Hmm..."]
            }
        }
    },
    "view" : "bootstrap-edit"
});
I have come up with two solutions for saving front-end JSON and one solution for saving data till now, but I don't think they are good enough, so I'm here asking for help to find a better one.
Save front-end JSON:
- list all the attributes of the front-end JSON, create a table with that and save all the value. It's not good to extend, if the package changes, I should update the table. the form field table is like: - | id | form_id | type | name | rows | ... | 
- resolve JSON to the key-value array and save it to the database. It's not good that if a user creates a form, he will insert a lot of rows to the table. the form field table is like: - | id | form_id | key | value | 
- save JSON as an attribute. I know Mysql 5.7 could support JSON, but I don't know if there are any other problems with this And Laravel 5.1 doesn't support JSON search. the form table is like: - | id | JSON | 
Save data JSON:
- resolve JSON to the key-value array and save it to the database. It's not good that if a user fills a form, he will insert a lot of rows to the table. the data table is like: - | id | form_id | key | value | 
Thanks~
 
     
     
    