jdorn / json-editor

JSON Schema Based Editor
MIT License
5.8k stars 1.08k forks source link

fix issue when boolean of type checkbox used in array with format table #809

Closed oguzgelal closed 3 years ago

oguzgelal commented 6 years ago

When boolean with checkbox format is used in an array with table format, following error occurs:

Uncaught TypeError: Cannot read property 'insertBefore' of undefined
    at e.getFormControl (jsoneditor.min.js.php:631)
    at e.build (jsoneditor.min.js.php:627)
    at jsoneditor.min.js.php:361
    at d (jsoneditor.min.js.php:64)
    at e.build (jsoneditor.min.js.php:361)
    at e.getElementEditor (jsoneditor.min.js.php:488)
    at e.addRow (jsoneditor.min.js.php:506)
    at jsoneditor.min.js.php:494
    at d (jsoneditor.min.js.php:64)
    at e.setValue (jsoneditor.min.js.php:492)

To reproduce, from the demo page:

1) Select HTML from the CSS Framework dropdown (the issue isn't reproducible on bootstrap themes, because they have their own implementation of the faulty method, the abstract theme file has the faulty implementation)

2) Use below schema:

{
  "title": "Test",
  "type": "object",
  "properties": {
    "pets": {
      "type": "array",
      "format": "table",
      "items": {
        "type": "object",
        "title": "Pet",
        "properties": {
          "visible": {
            "type": "boolean",
            "format": "checkbox"
          }
        }
      }
    }
  }
}

3) Add a new item to the array