Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

IN DEVELOPMENT: FEATURE IS CURRENTLY NOT AVAILABLE

Due to the dynamic nature of AffinityLive it's really difficult to determine what fields are available and required when creating and editing objects. The forms feature can be used to retrieve a list of required and optional fields for a given object or group of objects. Once you have selected the details you wish to store, you can then simply submit the form with the same endpoints.

Endpoints

(POST|GET) [/object_type1,object_type2,..object_typeN]/_forms/fields

Request fields for given object type(s). For example, 

$ curl -XGET /addresses,contacts/_forms/fields

would give you the fields for addresses and contacts available to the current user, so something like this:

{
    "response": {
		"fields": [[{
				"title": "Address",
				"fields": [{
					"key": "title",
					"title": "Title",
					"type": "text",
					"required": 1
				}, ...]
			}],[{
				... contact fields ...
			}]],
		}
	},
	"meta": { ... }
}

You can also pass the form information in as body data. This can be used to configure the forms, which we will discuss a little bit later in the document. For example,

$ curl -XPOST /_forms/fields -d'{
	"forms": [{
		"type": "addresses",
		"config": { ... configure addresses form ... },
	}, {
		"type": "contacts"
	}]
}';

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

  • forms : The forms for each object type, with optional configuration options.

We currently only support the following form object types, which are being used in our mobile applications:

  • addresses
  • companies
  • contacts

POST /_forms

Submit given object type(s). For example, the following would submit two forms- address and contact.

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

would create a contact and address with the supplied fields. The response will return the types and ids of the newly created objects.

{
    "response": {
		"submitted": [{
			"type": "address",
			"id": 112
		},{
			"type": "contact",
			"id": 1342
		}]
	},
	"meta": { ... }
}

The submit forms endpoint accepts the following parameters:

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


 

 

 

  • No labels