Subforms
Embed a form, within another form.
Using Subforms
The K.load function allows a form/submission to be loaded into the current page, it will be loaded and submitted via AJAX interactions.
Below is an example usage of the K.load function.
K.load({
path: '/kinetic/acme/catalog/ipad-request',
container: '#subform-div',
loaded: function(form) { ... },
created: function(data, action) { ... },
updated: function(data, action) { ... },
completed: function(data, action) { ... }
});
Options/Callbacks
pathpath to the form (including space, kapp, and form slugs) that will be loadedcontainerCSS selector that specifies where the loaded form should be placedloadedcalled after the form is loaded and appended to the page, it is passed the following parametersformthe Form object representing the loaded form, see Using Kinetic Objects for details
createdcalled after the page save/submission results in the successful creation of a new submission, it is passed the following parametersdatacontains the following propertiessubmissionthe submission API result, see the REST API documentation for details
actioncontains the following action functionsdefaultloads the next displayable page for the embedded submission, note that this is done automatically unless the stop action (below) is calledcloseremoves the embedded form from the pagestopprevents the default action from being done
updatedcalled after each save/submit following creation, it is passed the following parametersdatacontains the following propertiessubmissionthe submission API result, see the REST API documentation for details
actioncontains the following action functionsdefaultloads the next displayable page for the embedded submission, note that this is done automatically unless the stop action (below) is calledcloseremoves the embedded form from the pagestopprevents the default action from being done
completedcalled after page submit results in completion of the submission, it is passed the following parametersdatacontains the following propertiessubmissionthe submission API result, see the REST API documentation for details
actioncontains the following action functionsdefaultloads the confirmation page for the embedded submission, note that this is done automatically unless the stop action (below) is calledcloseremoves the embedded form from the pagestopprevents the default action from being done
unauthorizedcalled when the http request to load the form returns a status code of 401
(indicating the user making the request is not authenticated and the form requires authentication).
This callback is not passed any parameters.forbiddencalled when the http request to load the form returns a status code of 403
(indicating the authenticated user does not have access to submit the form).
This callback is not passed any parameters.notFoundcalled when the http request to load the form returns a status code of 404
(indicating that the kapp slug and form slug provided do not match a form).
This callback is not passed any parameters.errorcalled when the http request to load the form returns any status code that indicates
an error. Note that if one of the status codes mentioned above is returned, this callback will be
called in addition to the more specific callback. This callback is not passed any parameters.
Scenarios
- For a simple, one page, service item the created and completed callbacks will likely be called at the same time.
- For a multi-page service item, the created callback will be called upon submission of the first page. Any subsequent save or submit will result in the update callback being called. And finally, when the last page has been submitted the completed callback will be called.
Updated over 3 years ago
