application/json- (default) serializes the form fields as a JSON payload for any request method except for GET (form fields are url-encoded as query string parameters for GET requests)
application/x-www-form-urlencoded- the keys and values are encoded in key-value tuples separated by
'&', with a
'='between the key and the value. Non-alphanumeric characters in both keys and values are percent encoded.
text/plain- serializes the form fields as a JSON payload for any request method except for GET. This should only be used for a server that expects an
application/jsonpayload but does not include
Accept-Headerslist, or does not implement the
selectelements, which may contain any
email, password, firstName, lastName
user[name][last]will result in the following payload when encoded as
names, names, names.
didReceiveData. You may provide these as props to your React components, or register them using the
Masonglobal object (more on this below).
willSendDatawill receive the following arguments:
form- an object containing the following structure
name- the name of this form as provided in the Configure tab of the Builder, if specified; useful if you want to reuse the same callback across multiple forms
componentId- the id of the component, useful if you want to use the same callback across multiple components
formargument, but you should leave the top-level keys intact. Your callback may return one of the following two options:
falseor a Promise that rejects to abort form submission
formobject, mutated or not, or a Promise that resolves with the
willSendDatacallback, you must return one of these responses - if you want to submit the form data unmodified, simply
return format the end of your function. The value of
datawill be submitted to
2xxresponse code from a server in response to a form submission. It will receive the response body and the form
nameattribute as specified in the Configure section of the Builder.
actionblank, or return
Mason.callbackfunction. This function allows you to register a
callbackwithout using props, and has the following signature:
componentIdto provide a scoped callback for a single component id. Omitting the
componentIdargument will cause your callback to be invoked for every event of the specified type. Un-scoped callbacks are a useful place to perform universal actions like providing auth credentials.
Mason.callbackand a third registered as an un-scoped callback, they will be invoked in the order: prop, scope registered, un-scoped registered. The response from each preceding callbacks will be the first argument into the next callback in the chain.