alpacajs option configuration for submit button - json

27 views Asked by At

Alpaca looks like a nice plugin to build form with json, I am using it first time so I have few concerns in configuration

 $("#form").alpaca({
                                "schemaSource": ./Option/schema.json,
                                "options": "./option/Option.json",
                                
                                   "view": "bootstrap-create"
                            });

Schema.json

{
  "title": "Request Form ",
  "description": "",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "title": "Your Name",
      "required": true
    },
    "documentno": {
      "type": "string",
      "title": "Certificate Number"
    }
  }
}

Option.json

{
  "fields": {
    "name": {
      "size": 20,
      "label": "Your Name"
    },
    "documentno": {
      "size": 20,
      "label": "Document"
    }
  } 
  ,
  "form": {
            "buttons": {
                "submit": {
                    "title": "Show Results"
                }
            }
        }
 


}

This works fine but now I need more control on submit button,like there are other fields on my page that are not part of Alpaca form but I need to submit those values to the webservice along with alpaca form fields.

option.json is a json so not able to add click event inside json file, as then it gives error of invalid json

"form": {
            "buttons": {
                "submit": {
                    "title": "Show Results",
                    "click": function() {
                        alert(JSON.stringify(this.getValue()));
                    }
                }
            }
        }

I don't want to add entire option in script

  1. Can we have only fields coming from json, and form inside the alpaca script
  2. can we construct json to have script inside option.json
  3. Is there any other way to integrate this

Please suggest

0

There are 0 answers