json-schema-form/angular-schema-form

How work "condition"?

person2713 opened this issue · 1 comments

I don't understand how work "condition". Can you explain me, please? And how erase "undefined" from {"key": "Objects[].object.attributes[].value"}

`{
  "type": "object",
  "properties": {
    "name": {"type": "string"},
	"Objects": {
	 "type": "array",
	  "items": {
		"type": "object",
		"properties": {
		  "object": {
			"type": "object",
			"properties": {
			  "objectId": {
				"type": "string"
			  },
			  "attributes": {
				"type": "array",
				"items": {
				  "type": "object",
				  "properties": {
					"attributeId": {
						"type": "string"
					},
					"value": {
					  "type": "string"
					}
				  }
				}
			  }
			}
		  }
		}
	  }
	}
  },
"form": [
      {"key": "name"
      },
      {"key": "secname",
          "condition": {
                        "functionBody":"try { return model.name=='test'} catch(e){return false}"
                    }
      },
      {"key" :"Objects",
		"type": "array",
          "items": [
              {"key":"Objects[].object",
			   "items": [
                    {"key": "Objects[].object.objectId",
                        "htmlClass": "col-xs-6"
                    },
                    {"key": "Objects[].object.objectName",
                    "htmlClass": "col-xs-6",
                     "condition":
                     {
                        "functionBody":"try { return model.Objects[arrayIndex].object.objectId=='111'} catch(e){return false}"
                    },
                     "readonly": "true"
                    },
                    {
                        "key": "Objects[].object.attributes",
						"type": "array",
						"items": [
						    {"type": "section",
						      "htmlClass": "row",
						      "items": [
						          {
						              "type": "section",
						              
						              "items": [
						                  {"key": "Objects[].object.attributes[].attributeId"}
						                  ],
						                  "htmlClass": "col-xs-1"
						          },
						          {
						              "type": "section",
						              
						              "items": [
						                  {"key": "Objects[].object.attributes[].attrbuteName",
							                "condition": "",
							                "readonly": "true"
							                }
						                  ],
						                  "htmlClass": "col-xs-1",
						          }
						          ]
						    }
							,
							{"key": "Objects[].object.attributes[].value"}
						]
                    }
                ]
              }
          ]
      }
    ]
}`

I have to add items that I add on layout or it will work without this with condition?

@person2713 are you sure you didn't post in the wrong place again? That form code doesn't loook like ours.