ulion / jsonform

Build forms from JSON Schema. Easily template-able. Compatible with Twitter Bootstrap out of the box.
http://ulion.github.io/jsonform/playground/
MIT License
49 stars 27 forks source link

customFormItems doesn't support "disabled": true for nested items in a selectfieldset #23

Open epitomus opened 9 years ago

epitomus commented 9 years ago

Using customFormItems to customise sub-form items doesn't seem to support "disabled": true. In the following example, the "text.text1" field should be disabled:

{
  "schema": {
    "choice": {
      "type": "string",
      "enum": [ "text", "cat" ]
    },
    "text": {
      "type": "object",
      "properties": {
        "text1": {
          "type": "string",
          "title": "Text1"
        },
        "text2": {
          "type": "string",
          "title": "Text2"
        }
      }
    },
    "category": {
      "type": "string",
      "title": "Category",
      "enum": [
        "Geography",
        "Entertainment",
        "History",
        "Arts",
        "Science",
        "Sports"
      ]
    }
  },
  "form": [
    {
      "type": "selectfieldset",
      "key": "choice",
      "title": "Make a choice",
      "titleMap": {
        "text": "Search by text",
        "cat": "Search by category"
      },
      "items": [
        {
          "key": "text",
        },
        {
          "key": "category"
        }
      ],
     },
    {
      "type": "submit",
      "value": "Submit"
    }
  ],
  "customFormItems": {
    "text.text1": {
      "append": "today",
      "disabled": true
    },
    "text.text2": {
      "append": "tomorrow"
    }
  }
}
ulion commented 9 years ago

As I said, it's not "customFormItems", it's probably "selectfieldset" caused problem.

2015-08-17 14:04 GMT+08:00 epitomus notifications@github.com:

Using customFormItems to customise sub-form items doesn't seem to support "disabled": true. In the following example, the "text.text1" field should be disabled:

{ "schema": { "choice": { "type": "string", "enum": [ "text", "cat" ] }, "text": { "type": "object", "properties": { "text1": { "type": "string", "title": "Text1" }, "text2": { "type": "string", "title": "Text2" } } }, "category": { "type": "string", "title": "Category", "enum": [ "Geography", "Entertainment", "History", "Arts", "Science", "Sports" ] } }, "form": [ { "type": "selectfieldset", "key": "choice", "title": "Make a choice", "titleMap": { "text": "Search by text", "cat": "Search by category" }, "items": [ { "key": "text", }, { "key": "category" } ], }, { "type": "submit", "value": "Submit" } ], "customFormItems": { "text.text1": { "append": "today", "disabled": true }, "text.text2": { "append": "tomorrow" } } }

— Reply to this email directly or view it on GitHub https://github.com/ulion/jsonform/issues/23.

Ulion

epitomus commented 9 years ago

You are more likely to be right about this than I am :)

ulion commented 9 years ago

currently, you can use readonly as a workaround. since the selectfieldset operate on fields with disable/enable operations, it probably does not consider the disabled true case. PR is welcome if anyone want to fix it.

2015-08-17 14:20 GMT+08:00 epitomus notifications@github.com:

You are more likely to be right about this than I am :)

— Reply to this email directly or view it on GitHub https://github.com/ulion/jsonform/issues/23#issuecomment-131692150.

Ulion