Skip to content

documentTemplatesSubstore

Manages Carbone document templates that can be generated alongside a form submission. The SDK fetches applicable templates for the current session (based on configured form IDs and selected language), tracks which templates the user has selected, and sends the selection to the API on submit.

Templates are fetched automatically when at least one config exists and a language is selected. The query re-runs when the set of form IDs or the language changes.

Table of contents

Properties

Methods


Properties

templatesData

templatesData: ApiResource<{
templates: DocumentTemplate[];
enabled: boolean;
}>

API resource containing the applicable document templates and whether document generation is enabled for the current session.

Each DocumentTemplate has:

FieldTypeDescription
idnumberTemplate ID sent to the API on submit
namestringDisplay name
output_format"pdf" | "docx" | "odt" | "xlsx" | "ods"Generated file format
selection_mode"locked" | "selected" | "deselected"Default selection behaviour (see below)

When enabled is false or no templates apply, templates is an empty array. Your UI can hide the document-template picker in that case.

See ApiResource for loading and error state.

Related


selectedTemplateIds

selectedTemplateIds: Set<number>

Set of template IDs the user has chosen to generate on submit.

Selection is reconciled automatically when the applicable template list changes:

  • locked — always included; cannot be toggled off
  • selected — included by default when the template first appears
  • deselected — not included by default; the user must opt in

Previously selected IDs that are no longer applicable are removed automatically.

Related


Methods

toggleTemplate

toggleTemplate: (templateId: number) => void

Toggles a template in selectedTemplateIds.

Does nothing when the template is not found or its selection_mode is "locked".

Parameters

NameTypeDescription
templateIdnumberID of the template to toggle

Related