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

How to use layout with nested fields in form? #596

Open apaokin opened 6 years ago

apaokin commented 6 years ago

Good morning I want to point out directly fields' reference to divs (something like in commented out piece of code). How can I achieve this?

$("#group_classes_form").alpaca({
    "schema": {
        "type": "object",
        "properties": {
          "group_class":{
            "type": "object",
            "properties":{
              "group_id":{
                "title": group_title,
                "enum": group_options,
                "required": true
              },
              "class_name":{
                "title": class_title,
                "enum": class_options,
                "required": true
              }

            }
          }
        }
    },
    "options":{
      "focus":"",
      "hideInitValidationError":true,
      "fields":{
        "group_class":{
          "fields":{
            "group_id":{
              "validate": false,
              "type": "select",
              "optionLabels": group_labels
            },
            "class_name":{
              "validate": false,
              "type": "select",
              "optionLabels": class_labels
            }
          }
        }
      },
    "view": {
      // "layout": {
      //     "template": "<%=j render partial: 'form_layout' %>",
      //     "bindings": {
      //       "group_class":
      //       {
      //         "group_id": "#column-1",
      //         "class_name" : "#column-2"
      //       }
      //     }
      //   }
    }
  },
  "postRender": function(control) {
    apply_select();
  }
});