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:
| Field | Type | Description |
|---|---|---|
id | number | Template ID sent to the API on submit |
name | string | Display 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— user selection derived from this datasubmitSubstore.submit— sends selected template IDs to the APIsubmitSubstore.isSubmitEnabled— submit is disabled while this resource is loading
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 offselected— included by default when the template first appearsdeselected— not included by default; the user must opt in
Previously selected IDs that are no longer applicable are removed automatically.
Related
toggleTemplate— add or remove a template from this setsubmitSubstore.submit— reads this set asdocument_template_ids
Methods
toggleTemplate
toggleTemplate: (templateId: number) => voidToggles a template in selectedTemplateIds.
Does nothing when the template is not found or its selection_mode is "locked".
Parameters
| Name | Type | Description |
|---|---|---|
templateId | number | ID of the template to toggle |
Related