Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
{
    "response": {
		"forms": [{
			"form_type": "addresses",
			"fieldsform_content": [{
				"section_title": "Address",
				"fieldssection_content": [{
					"input_key": "title",
					"input_title": "Title",
					"input_type": "text",
					"input_options": [],
					"input_placeholder": "Your address..",
					"input_description": "This is your postal address.",
					"multiple_values" : 0,
					"required": 10
				}, ...]
			}]
		},{
			"form_type": "contacts",
			"fieldsform_content" : [{
				... contact fields ...
			}],
		}]
	},
	"meta": { ... }
}

...

Code Block
languagebash
$ curl -XPOST /_forms/fields -d'{
	"forms": [{
		"form_type": "addresses",
		"form_config": { ... configure addresses form ... },
	}, {
		"form_type": "contacts"
	}]
}';

would return a similar structure of fields. The fields endpoint accepts the following parameters:

...

Code Block
languagebash
$ curl -XPOST /_forms -d '{
	"forms": [{ 
		"form_type": "addresses",
		"form_config": { ... }
		"form_data": {
			"title": "My new address",
			"link" : {
				"type": "company",
				"id": 100
			},
			...
		}
	},{
		"form_type": "contacts",
		"form_data": {
			"contact.firstname": "Kurt",
            "affiliation.email": "abc@example.com",
			...
		}
	}]
}';

...

  • forms : The forms for each object type, with optional configuration options.
  • submit : The data you wish to submit for each type of form.

Linking new objects

When working with the input type "object" you're required to pass back a "type" and "id" of an existing object or "type" and "form", where "form" is an associative array of fields from that object's form. For example, the following will create a new company with a new physical address linked to it. 

Code Block
languagebash
$ curl -XPOST /_forms -d '{
	"forms": [{ 
		"form_type": "companies",
		"form_config": { ... }
		"form_data": {
			"company.name" : "Kurt's sample company",
			"company.website": "http://www.kurts-sample-company.com",
			"company.physical_address" : {
				"type": "address",
				"form": {
					"form_type": "addresses",
					"form_config": { ... }
					"form_data": {
						"address.title" : "Kurt's sample address",
						"company.street1": "24323 Kurt's Test Street",
						"company.postcode": "2500",
						...
					}
				}
			},
			...
		}
	}]
}';

 The "form" attribute is only supported for object's that are supported by this forms feature.

Multiple Value Support

There are some objects that support multiple values. These are indicated with a 1 in "mutiple_values" attributes from the fields endpoint. For example, companies can support multiple addresses. The following the creates a new physical address and links an existing address with id "1342".

Code Block
languagebash
$ curl -XPOST /_forms -d '{
	"forms": [{ 
		"form_type": "companies",
		"form_config": { ... }
		"form_data": {
			"company.name" : "Kurt's sample company",
			"company.website": "http://www.kurts-sample-company.com",
			"company.physical_address" : [{
				"type": "address",
				"id": 1342
			},{
				"type": "address",
				"form": {
					"form_type": "addresses",
					"form_config": { ... }
					"form_data": {
						"address.title" : "Kurt's sample address",
						"company.street1": "24323 Kurt's Test Street",
						"company.postcode": "2500",
						...
					}
				}
			}],
			...
		}
	}]
}';