There is a group of fields in the repeater. These fields also contain the “repeater” field type, and in this field there are two fields of the type “richeditor” - the contents of the richeditor fields are swapped when saved and can even go to a neighboring repeater.
This error occurs randomly. It appears for me when the model is saved multiple times during the development of this interface.
Additional question:
Is it possible to save $jsonable without json_encode/json_decode and write the Cyrillic alphabet to the database immediately in utf-8?
Failed to create stable conditions for this error to occur. The error appears randomly and very rarely (about 1 case per 10-15 code changes). But I found out when it might appear - this is not saving the model. The confusion occurs if you change the order of the fields in the repeater in the yaml file and update the OPEN interface of the model backend without ctrl+f5.
Sorting fields in yaml and immediately saving the backend form without updating does not affect the order of the data. Or I didn’t have the patience to run more tests.
Is it possible to save $jsonable without json_encode/json_decode and write the Cyrillic alphabet to the database immediately in utf-8?
I managed to do this in one of my projects by using custom getter / setter. It looks something like this:
public function setContentAttribute($value) {
$this->attributes['content'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
public function getContentAttribute($value) {
return json_decode($value, true);
}
This should probably be the default behavior of jsonable attributes though…
I managed to find steps that consistently cause an error. Data confusion occurs after deleting a field in the repeater and then saving the data.
Scr-1 is the structure of my yaml file
scr-2 - one of the repeaters with entered data
scr-3 - add a new field to the repeater and F5 - refresh the page to see the changes
save data
scr-4 – deleting a field from the repeater and saving the data, → changing one of the repeater fields.
Depending on where the field is removed from, changes can occur anywhere. Changes may also appear in a neighboring repeater from the groups: $/konvertagency/landing/models/page/listcontent.yaml