Skip to content

Instantly share code, notes, and snippets.

@kivi
Created August 21, 2012 11:11
Show Gist options
  • Save kivi/3414600 to your computer and use it in GitHub Desktop.
Save kivi/3414600 to your computer and use it in GitHub Desktop.
collection-json extension template options

Template Data Validation

Support template data options by adding property attribute with an array of prompt and value. Additionally add a muliple property, which indicates multiple values are suppored if set "true".

  1. Add an optional property to the data object: option (array of and object. prompt/value pair)
  2. Add an optional property to the data object: multiple (boolean). This property has no impact if option property is not set.
{ "collection" :
  {
    "version" : "1.0",
    "href" : "http://example.org/users",

    "template" : {
      "data" : [
        { "name" : "username", "value" : "", "prompt" : "User name", "required" : "true" },
        { "name" : "country", "value" : "", "prompt" : "Country", "multiple" : "false"  "options" : [ { "prompt" : "Germany", "value" : "de" }, { "prompt" : "Poland", "value" : "pl" } ] },
		{ "name" : "talents", "value" : "", "prompt" : "Talents", "multiple" : "true", "required" : "true", "options" : [ { "prompt" : "Swimming", "value" : "swimming" }, { "prompt" : "Climbing", "value" : "climbing" }, { "prompt" : "Socializing", "value" : "socializing" } ] },
      ]
    }
  }
}

References

  1. https://groups.google.com/d/msg/collectionjson/PQK5PoB7eSI/-TQgtjFTeqsJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment