gitana / alpaca

Alpaca provides the easiest way to generate interactive HTML5 forms for web and mobile applications. It uses JSON Schema and simple Handlebars templates to generate great looking, dynamic user interfaces on top of Twitter Bootstrap, jQuery UI, jQuery Mobile and HTML5.
http://www.alpacajs.org
Other
1.29k stars 371 forks source link

x-depends-on doesn't let me use already conditional field #663

Closed morgunder closed 6 years ago

morgunder commented 6 years ago

This is a snippet of my .json file and you'll noticed that both skill_ids and servicesubtype_id are dependent on servicetype_id. what i need to do now is to convert skill_ids to be dependent on servicesubtype_id but it does not work.

observations a. skill_ids: when i have "x-depends-on": "servicetype_id" ajax appends ?servicetype_id=20 b. skill_ids: when i have "x-depends-on": "servicesubtype_id" ajax appends nothing.

please help

     "fields": {
       "servicetype_id": {
            "label": "Service Type",
            "type": "select",
            "dataSource": "/partner/select/servicetypes",
            "noneLabel": "Choose One...",
            "validate": false
        },
        "servicesubtype_id": {
            "label": "Service Subtype",
            "type": "select",
            "dataSource": "/partner/select/servicesubtypes",
            "noneLabel": "Choose One...",
            "validate": false,
            "x-depends-on": "servicetype_id"
        },
        "skill_ids": {
          "label": "Skills",
          "type": "select",
          "dataSource": "/partner/select/skills",
          "multiple": true,
          "removeDefaultNone": true,
          "validate": false,
          "x-depends-on": "servicesubtype_id"
        }
    }
morgunder commented 6 years ago

figured it out - but i do think you should support conditional selects a bit easier

ZaLiTHkA commented 5 years ago

@morgunder could you perhaps share some details of how you fixed this one..?

I've currently got two select list fields that depend on the value of another select list field further up, all of which are configured to load their select options using the dataSource callback..

these do all exist within the same form, as you have in the snippet you posted above.. I found #562 proposing that the form is split into two, deferring the load of the latter until the first one is complete... is that what you had to do, or did you find another way around this?