Skip to main content

Form templates

Overview​

A form template is a starter form. An admin picks it on the page that opens from Content → WebForms → Manage Forms → Add Form. Your module can add templates of its own, and categories to sort them into.

A template takes two files in your module:

  • an entry in etc/webforms_templates.xml;
  • the form itself, as JSON, in etc/form_templates/.

Magento merges etc/webforms_templates.xml from all modules by id. An entry with the same id as another module's replaces it.

Add a template​

The Product Request add-on adds its Product Inquiry template like this:

<webforms_templates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:MageMe_WebForms:etc/webforms_templates.xsd">
<template id="product_inquiry" order="85">
<label>Product Inquiry</label>
<description>For the Product Request popup, which names and attaches the product. Questions are sorted by topic, and each topic asks for its own details.</description>
<category>products_quotes</category>
<body>MageMe_WebFormsProductRequest::product_inquiry.json</body>
<icon>chat</icon>
<setup_note>The customer's copy is sent from Sales Representative: check that address in Stores > Configuration > General > Store Email Addresses.</setup_note>
</template>
</webforms_templates>
Element Required What it holds
template id, order Yes A unique id, and the position in its category
label, description Yes The name, and the line under it in the template list
category Yes The id of a declared category. WebForms declares support_feedback, orders_returns, products_quotes, b2b_wholesale and signups_bookings. A template whose category isn't declared is left out, with a warning in the log.
body Yes Vendor_Module::file.json, read from etc/form_templates/file.json of that module. The file uses the format of Form document schema.
icon No The icon in the list: quote, quotes, chat, megaphone, phone, box, building, hands, truck, refund, shield, star, gauge, clipboard, calendar, clock, briefcase, mail, inbox, card, bell, tag, pen, ticket, send, user or file. Any other value shows file.
setup_note No A note shown as Before You Publish
companions No Empty flags approval, reference_number, statuses, customer_account: features the admin may switch on with the template

An empty label, description, category or body fails the merge with an exception.

Add a category of your own​

Give your category an id of your own. An entry with a core id would replace that category's label and order. A category element takes an id, an order and a label.

In your module's etc/webforms_templates.xml, a category of your own and a template in it that lists two companions flags:

<category id="northstar_fabrics" order="60">
<label>Fabric Samples</label>
</category>
<template id="northstar_swatch_request" order="10">
…
<category>northstar_fabrics</category>
<companions>
<reference_number/>
<customer_account/>
</companions>
</template>

What's next​

Applies to WebForms 4Last reviewed December 2, 2026