Saves form values in the local storage while the user fills out the form. The values are restored every time the user returns to the form page.

Is optimized to work with the hylo-form components set and the Django crispy hylo-form templates.

Wrap the form with this component.

The process of saving the values is automated but functions for saving and loading values are provided.

The clearing of the storage needs to be called manually.

Properties

manualInitialization: boolean

If not set, the storage will be initialized when the component gets loaded. With the initialization saved data in the storage will be set to the wrapped form components. This will result in errors if the form components aren't ready yet.

Set the initialization to manual and call the initialization function when all form components are present.

name: string = 'application_form_values'

The unique name of the storage.

silence: boolean

Disables the storage in a way that it is still doing its thing but does not restore/initialize the values of the form every time the user returns to the form page.

Methods

  • Clears the storage.

    Returns Promise<void>

  • Deletes a form value from the storage.

    Parameters

    • id: string

    Returns Promise<void>

  • Initializes the storage. Saved data in the storage will be set to the wrapped form components.

    Is called automatically when the component is loaded and not set to manual.

    Returns Promise<void>

  • Returns if the storage is setup.

    Returns Promise<boolean>

  • Loads a form value from the storage and returns it as object {type, value}.

    Parameters

    • id: string

      the id of the form field

    Returns Promise<any>

  • Save a value to the storage.

    Parameters

    • type: string

      the type of the form field ('hylo-date', 'hylo-input', 'hylo-textarea', 'hylo-checkbox-group', 'hylo-checkbox', 'file', 'inline', 'select')

    • id: string

      the id of the form field

    • value: string

      the value of the form field

    Returns Promise<void>

  • Saves changes to an inline formset. Needs to be called manually every time a set from the inline formset gets removed. Does NOT need to be called when a new set got added.

    You have to gather the values and types of all remaining form components of the inline formset in a storage object: storage["id_of_form_component"] = {type: "form_component_type", value: "form_component_value"}

    Possible types are: 'hylo-date', 'hylo-input', 'hylo-textarea', 'hylo-checkbox-group', 'hylo-checkbox', 'file', 'select'

    Check the code of this component to see how the values are formatted.

    Parameters

    • id: string

      id of the inline formset

    • total: number

      the totalForms value of the inline formset

    • storage: object

      the storage object

    Returns Promise<void>

Events

hyloInitialized: EventEmitter<any>

Is fired after initialization.

Generated using TypeDoc