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 loaded
  • container CSS selector that specifies where the loaded form should be placed
  • loaded called after the form is loaded and appended to the page, it is passed the following parameters
    • form 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 parameters
    • data contains the following properties
      • submission the submission API result, see the REST API documentation for details
    • action contains the following action functions
      • default loads the next displayable page for the embedded submission, note that this is done automatically unless the stop action (below) is called
      • close removes the embedded form from the page
      • stop prevents the default action from being done
  • updated called after each save/submit following creation, it is passed the following parameters
    • data contains the following properties
      • submission the submission API result, see the REST API documentation for details
    • action contains the following action functions
      • default loads the next displayable page for the embedded submission, note that this is done automatically unless the stop action (below) is called
      • close removes the embedded form from the page
      • stop prevents the default action from being done
  • completed called after page submit results in completion of the submission, it is passed the following parameters
    • data contains the following properties
      • submission the submission API result, see the REST API documentation for details
    • action contains the following action functions
      • default loads the confirmation page for the embedded submission, note that this is done automatically unless the stop action (below) is called
      • close removes the embedded form from the page
      • stop 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.