How to save data from a model in 1 cell database?

A model for forms with lots of fields they can change, etc.
There is a model for a table (user_id, data)
Question 1:
how should I store the serialize, json, options?
Question 2: how best to access the data model of the form?
$model - will provide an object that is not necessary, $model->atributes returns only the field names. Something pereklinilo me.
July 9th 19 at 10:47
1 answer
July 9th 19 at 10:49
Solution
how should I store the serialize, json, options?
Roughly speaking, json is better and faster. Serialize the if to push to the database objects own class, what you probably do not need.

how to access the data model of the form?
In the model write method such as getDataAsModel(){...}, which will return the DynamicModel your json_decode($this->data);
After our submission on the client Controller should take the data in the same dynamic model is derived from getDataAsModel(){...}, call validation and put it in a method setMyDataModel($dinModel)that will do what you need and put $this->data = json_encode($data);

Docks.
www.yiiframework.com/doc-2.0/yii-base-dynamicmodel.html
In fact did the same, only instead of the usual dynamic models. The customer wants to have the ability in the admin to change the form, thinking to make a generator which will overwrite the model file and all. Don't know if this is correct, perhaps with a dynamic model correctly. Thanks for the idea. - Henderson_Beat commented on July 9th 19 at 10:52

Find more questions by tags Yii