Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

FormioResource Provider

Travis Tidwell edited this page Jan 13, 2017 · 18 revisions

The FormioResource provider allows you to register your Form.io Resources so that all of your UI Router CRUD states will be registered for you. In almost every case, a FormioResource will be registered for any Resource you have within your Form.io project. For example, if you create a Customer Resource within your Form.io project, a new FormioResource will be registered to represent the CRUD operations for that Customer within your application.

For every resource registration, there are 5 main states that you need to be concerned with when working with the FormioResource provider.

  • Index: This is the view which shows all of the submissions for a Resource within Form.io. This view by default is provided by the ngFormioGrid library.
  • Create: This state is the "C" in CRUD which is used to create a new resource record (also called Submission in Form.io). This will render the form for that resource.
  • Abstract: This state is used as the resource instance container for the Read, Update, and Delete states. It provides the overarching controller which loads the resource instance and provides that resource instance to all of the sub states. This is a UI Router abstract state, which means you cannot actually navigate to this state, but rather just serves as the container for the Read, Update, and Delete states within it.
  • Read: This state provides the "view" of the resource submission.
  • Update: This state provides the means to update the resource submission.
  • Delete: This state provides the ability to delete the resource submission.

Resource Registration

After you have created a Resource within your Form.io project, the first task will be to bring in that Resource into your application. This can be done by "registering" that resource within your application using the FormioResource.register method as follows.

FormioResource.register(name, url, options)

Name Type Description
name String The name of the resource you created and wish to represent within your application. Example: For a **Customer** resource, this would probably be 'customer'
url String The URL to the Resource form within Form.io. Example: https://myproject.form.io/customer
options Object The options for this provider as follows.
Property Description
title The title to show for the resource within the Abstract view.
base The UI Router state that is the parent to this resource. This is handy for representing nested resources.
parent The name of the parent resource.
parents The names of all the "parent" resources for this resource. These are not UI router states, but rather just the names of the resources which are parents.
alter An object of alter handlers. See **Altering states** below
defaultValue The default value to provide to the Submission when creating a new resource in the Create state.
endpoint A custom endpoint to retrieve data for the Abstract state. Good for integration with external systems.
templates Overrides to the templates provided to each main state. See **Overriding Templates** below.
controllers Overrides to the controllers provided to each main state. See **Overriding Controllers** below.
query The query parameters to add to the UI Router states. See [UI Router Query Params](https://github.com/angular-ui/ui-router/wiki/URL-Routing#query-parameters)
params An object for the params to pass to each state for UI Router states. See **Adding state params** below.
data An object for the data to pass to each state for UI Router states. See **Adding state data** below.
breadcrumb Adds a breadcrumb (thanks to [Angular BreadCrumb](https://github.com/ncuillery/angular-breadcrumb) to the Resource. See **Adding Breadcrumbs** below.

Overriding Templates

TO-DO

Overriding Controllers

TO-DO

Altering States

TO-DO

Adding State Parameters

TO-DO

Adding State Data

TO-DO

Adding State Breadcrumbs

TO-DO

Clone this wiki locally