Messed up and duplicated values in JSON keys while maintaining "repeater" type field. v3.0.59

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?

Are you able to get this to happen reliably instead of randomly? It might be something to do with the Froala editor.

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.

Try performing the sort and then immediately save the record. It could be a race condition where the HTML hasn’t finished moving. Just a guess…

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…

1 Like

If this doesn’t impact the current behavior, a pull request would be accepted for this.

1 Like

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.

  1. Scr-1 is the structure of my yaml file

  2. scr-2 - one of the repeaters with entered data

  3. scr-3 - add a new field to the repeater and F5 - refresh the page to see the changes

  4. save data

  5. 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




1 Like