Skip to content

Issue when checkboxes are used inside tabarray #588

Closed
@catchshyam

Description

@catchshyam

Hello,
I am facing issue with checkboxes inside tabarray. I am using 0.8.12 with latest development branch of bootstrap decorator

Schema:

{
  "type": "object",
  "title": "Test Checkboxes",
  "properties": {
    "test": {
      "type": "array",
      "default": [],
      "items": {
        "type": "object",
        "properties": {
           "likes": {
               "type": "array",
               "title": "I like",
               "items": {
                   "type": "string",
                   "enum": [
                      "1",
                      "2",
                      "3"
                ]
            }
        }

        },
        "required": [
          "likes"
        ]
      }
    }
  }
}

Form:

[
    {
        "key": "test[].likes",
        "type": "checkboxes",
        "title": "I like",
        "titleMap": [
            {"name": "Series", "value": "1"},
            {"name": "Movies", "value": "2"},
            {"name": "Music", "value": "3"}
        ]
    }
]

Let's say I create tab 2 and select movies in checkboxes. Now if I create tab 3, on the new tab, movies will be selected. From now on, any check box selection in tab 3 will also alter the selection in tab 2.

The issue is that the array that gets assigned to the model object is the default object defined in the schema. In my opinion, bug lies in the below function in sfNewArray,

      // If model is undefined make sure it gets set.
      var getOrCreateModel = function() {
        var model = scope.modelArray;
        if (!model) {
          var selection = sfPath.parse(attrs.sfNewArray);
          model = [];
          sel(selection, scope, model);
          scope.modelArray = model;
        }
        return model;
      };

The object that gets assigned to the model array must be the clone of schema defaults I guess.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions