json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

TabArray fails when title has spaces #276

Closed Coridyn closed 9 years ago

Coridyn commented 9 years ago

In tabarray.html if the form.title is a string containing spaces then the interpolation will fail.

I've made a demo showing the issue: https://github.com/Coridyn/angular-schema-form/tree/demo/tabarray-broken (Select the "Tab Array (Broken)" example)

and here is a schema+form that does the same thing:

{
  "schema": {
    "type": "object",
    "title": "Comment",
    "properties": {
      "breaks": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "title": "Name",
              "type": "string"
            }
          },
          "required": ["name"]
        }
      }
    }
  },

  "form": [
    {
      "type": "help",
      "helpvalue": "<h4>This tabarray breaks when the `title` has spaces:</p>"
    }, 
    {
      "key": "breaks",
      "type": "tabarray",
      "title": "My name",
      "items": [
        "breaks[].name"
      ]
    }
  ]
}

The tabarray.html template tries to interpolate form.title which will fail if it contains spaces (because it's not a valid Angular expression):

<a href="#">{{evalExpr(form.title,{'$index':$index, value: item}) || $index}}</a>
davidlgj commented 9 years ago

Thanks again!