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
path
path to the form (including space, kapp, and form slugs) that will be loadedcontainer
CSS selector that specifies where the loaded form should be placedloaded
called after the form is loaded and appended to the page, it is passed the following parametersform
the Form object representing the loaded form, see Using Kinetic Objects for details
created
called after the page save/submission results in the successful creation of a new submission, it is passed the following parametersdata
contains the following propertiessubmission
the submission API result, see the REST API documentation for details
action
contains the following action functionsdefault
loads the next displayable page for the embedded submission, note that this is done automatically unless the stop action (below) is calledclose
removes the embedded form from the pagestop
prevents the default action from being done
updated
called after each save/submit following creation, it is passed the following parametersdata
contains the following propertiessubmission
the submission API result, see the REST API documentation for details
action
contains the following action functionsdefault
loads the next displayable page for the embedded submission, note that this is done automatically unless the stop action (below) is calledclose
removes the embedded form from the pagestop
prevents the default action from being done
completed
called after page submit results in completion of the submission, it is passed the following parametersdata
contains the following propertiessubmission
the submission API result, see the REST API documentation for details
action
contains the following action functionsdefault
loads the confirmation page for the embedded submission, note that this is done automatically unless the stop action (below) is calledclose
removes the embedded form from the pagestop
prevents the default action from being done
unauthorized
called 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.forbidden
called 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.notFound
called 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.error
called 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 almost 3 years ago