Skip to main content

Theme and template overrides

What it does​

Replace any storefront template of WebForms from your own theme, and add CSS that wins over the form's own stylesheet rules of equal weight without !important. Templates follow the standard Magento theme fallback, so a copy in <theme>/MageMe_WebForms/templates/ replaces the module's file on every store view that uses your theme. The examples use a theme named Northstar/furniture; put your own vendor and theme name in its place.

Which template draws what​

Paths are relative to view/frontend/templates/ of the module, and to MageMe_WebForms/templates/ in a theme.

Template Draws
form/default.phtml The frame around a form on its own page, in a widget, in a CMS block or on the contact page: the form stylesheet, the success and error messages, then the form.
form/slide_out.phtml The slide-out panel and its tab.
form/register.phtml The form that replaces the customer registration page.
contact/form.phtml The container that replaces Magento's contact form. The form inside it uses its own frame.
form/multistep.phtml, form/sidebar.phtml Older frames. View Template in the form's Design settings now offers only Default; a form that stored one of these keeps rendering it.
form/element/form.phtml The <form> element of a single-page form, with its sections.
form/multistep/form.phtml The <form> element of a multi-step form, with the step strip and navigation.
form/element/fieldset.phtml One section.
form/element/field.phtml The wrapper of one field: label, hint, error.
form/element/field/type/*.phtml The input of one field type. The file name is set in the field's block under Block/Form/Element/Field/Type/, for example email.phtml or stars.phtml.
form/element/actions-toolbar.phtml The row with the submit button.
form/element/captcha/type/*.phtml The reCAPTCHA, hCaptcha and Turnstile widgets.
popup.phtml, button/default.phtml The popup container and the button of the WebForms: Button With Popup widget.
form/slot.phtml The room a form keeps on the page until the browser loads it in. It holds nothing that varies per visitor, so a shared cache keeps it.
fragment.phtml The wrapper of a form fragment, the HTML a popup, a slide-out or a slot loads from the webforms/form/fragment route. The old form/popup and form/load routes are gone and answer 404.
result/default.phtml, result/carousel.phtml The list and carousel of the WebForms: Results widget.
customer/account.phtml and customer/account/** The customer's submissions in My Account.

The page shown for a form closed to the visitor's customer group is a layout file, not a template: view/frontend/layout/webforms_form_view_restricted.xml in the module, MageMe_WebForms/layout/ in a theme.

Which frame a form uses is decided in MageMe\WebForms\Block\Form: the slide-out and the registration page set their own, every other placement uses the form's View Template.

Before you start​

  • A child theme of Luma, Hyvä or Breeze, assigned to the store view in Content → Design → Configuration.
  • File access to the store and a shell where you can run bin/magento.
  • Developer mode while you work, so a template that breaks a popup form fails loudly. See Limits.
  • If you want forms to take your theme's look, you may not need a template at all. See Make forms look like your theme.
  • If you only want to change colors, corners or spacing, check first whether the Appearance settings or a --wf-* token already does it. See Styling contract.

Steps​

Override a template on Luma​

  1. Find the template in the module: vendor/mageme/module-webforms-base/view/frontend/templates/ for a Composer install, or app/code/MageMe/WebForms/view/frontend/templates/ for a copy in app/code.

  2. Copy it into your theme under MageMe_WebForms/templates/, keeping the path below templates/:

    app/design/frontend/Northstar/furniture/MageMe_WebForms/templates/form/default.phtml
  3. Edit your copy. Keep the element ids built from the uid (webform_<uid>, webform_<uid>_form, webform_<uid>_success_text) and the wfPart, wfField and wfRoot calls. The form script finds the form by those ids, and stylesheets rely on the attributes the calls print.

  4. Clean the cache:

    bin/magento cache:clean

Override a template on Hyvä​

On a Hyvä theme the companion module Hyva_MageMeWebForms replaces most core templates through Hyva_CompatModuleFallback. Your theme still comes first in the fallback, so you override the companion's file from the same place as on Luma.

  1. Copy the companion's template, not the core one: vendor/mageme/module-webforms-base-hyva/view/frontend/templates/ for a Composer install, or app/code/Hyva/MageMeWebForms/view/frontend/templates/. If the companion has no copy of the file, take the core template.

  2. Put it under MageMe_WebForms/templates/ in your Hyvä theme, the folder of the original module:

    app/design/frontend/Northstar/furniture/MageMe_WebForms/templates/form/element/field/type/email.phtml

    A template the companion addresses by its own name, such as Hyva_MageMeWebForms::button/opener.phtml or Hyva_MageMeWebForms::page/js/dependencies.phtml, goes under Hyva_MageMeWebForms/templates/ instead. The companion's own static files carry a hyva- prefix, so they never take the path of a core file: js/hyva-submit.js, css/hyva-dynamic-grid.css, css/hyva-account.css, css/field/hyva-rating.css and js/field/hyva-region.js. An override of one of them in your theme uses that name, under Hyva_MageMeWebForms/web/.

  3. Edit your copy. Keep its x-data attributes and the ids and contract calls named in the Luma steps. If you need a new Alpine component, register it from a page-level script; the companion registers its own from page/js/dependencies.phtml.

  4. If you added Tailwind classes, rebuild your theme's stylesheet:

    cd app/design/frontend/Northstar/furniture/web/tailwind
    npm run build
  5. Clean the cache with bin/magento cache:clean.

Override a template on Breeze​

The Breeze companion MageMe_WebFormsBreeze ships no templates: Breeze storefronts render the core templates.

  1. Copy the core template into your Breeze child theme under MageMe_WebForms/templates/, as in the Luma steps.
  2. Edit your copy and clean the cache.

Add CSS through the theme stylesheet​

On Luma and Breeze the form prints its styles inline, next to the form, and then prints one file your theme can fill: MageMe_WebForms/web/css/form-theme.less. Because it comes last, your rules win on equal weight.

  1. Create the file in your theme:

    app/design/frontend/Northstar/furniture/MageMe_WebForms/web/css/form-theme.less
  2. Keep the module's marker line at the top, then write your rules against the Styling contract:

    :root { --wf-form-theme: 1; }

    [data-wf-part~="form"] {
    --wf-card-bg: #f7f3ee;
    }

    [data-wf-part~="field"][data-wf-state~="required"] [data-wf-part~="field-label"] {
    font-weight: 600;
    }
  3. Make Magento build the file again. It keeps a processed copy of the file for each theme and locale, and prints that copy until it's gone. Delete the copy of the theme and locale your storefront uses, then clean the full page cache if it's on:

    rm var/view_preprocessed/pub/static/frontend/Northstar/furniture/en_US/MageMe_WebForms/css/form-theme.less
    bin/magento cache:clean full_page

    This works the same in developer and production mode. A cache clean alone doesn't pick up the change, and neither does setup:static-content:deploy: the form prints the file inline from its source, not from pub/static.

The file can't import your theme's LESS variables or mixins: Magento refuses a path outside the module's folder. Write the values themselves. A LESS error in the file, such as an unknown variable, drops all its rules without a message: the page loads, nothing is written to the log or the browser console, and a static content deploy reports no error.

On Hyvä the form frame doesn't print this file. Put form CSS in your theme's Tailwind source and rebuild.

Show a form from your own template​

To show a form inside a template of your theme, create the form block there. It takes the form's id, or its code as webform_code:

<?= /* @noEscape */ $block->getLayout()
->createBlock(\MageMe\WebForms\Block\Form::class, 'northstar.footer.form', ['data' => ['form_id' => 12]])
->toHtml() ?>

12 stands for your form's id. The same block in layout XML is shown in Getting started for developers.

What you should see​

  • The form renders from your copy on every store view that uses your theme. On Hyvä, a form drawn from the companion's templates still carries attributes such as x-data="mmWebformsEmailData" on an Email field.

  • On Luma and Breeze, your form-theme.less rules appear in the page inside the inline <style> printed before the form. The marker line alone prints nothing.

  • The read-only audit reports clean fragments for the form you changed:

    bin/magento webforms:report templates --form=995080
    26 fragment(s) rendered; none carries an executable script.

    995080 is the form id. The audit renders the form's popup fragment in each store view under that store view's theme, so the count depends on your store views. Leave out --form to check every active form.

Limits​

  • No executable <script> in a form template. A form fetched into a page arrives as a fragment, and a fragment carries data only. That covers the WebForms: Button With Popup widget, the New Submission dialog in My Account, and the slide-out form when Fetch Slide-Out Form on First Open is on. Only application/json, text/x-magento-init and text/template scripts without src are allowed. In developer mode the request for such a fragment fails with "fragments carry data only". In production the fragment is delivered, but its script never runs, so whatever depends on that script doesn't work. bin/magento webforms:report templates renders the popup fragment of each active form in each store view and names the templates that printed an executable script into it. It sees only what those renders print, so test other placements yourself. Put your own code in the theme or in the form's On Load Script.
  • One copy applies to every form that uses the template, on every store view of the theme. The theme fallback can't pick a template per form.
  • Your copy doesn't receive the module's fixes. Compare it with the module's file after each WebForms update.
  • A form inside another form prints as a container. When an add-on places a form inside another form, as the Product Options form sits inside the add-to-cart form, the form block carries \MageMe\WebForms\Block\Form\Element\Form::INLINE_CONTAINER, and the module's form/element/form.phtml and form/multistep/form.phtml print a <div> instead of a <form> (the $_inline branches). A copy of either template in your theme, on Luma, Breeze or Hyvä, takes over those branches. A copy of form/default.phtml that prints a <form> tag itself prints a <div> when $block->getFormBlock() carries the flag. Otherwise the options form prints as a <form> inside the add-to-cart form, which browsers don't allow.
  • form-theme.less works on Luma and Breeze only.
  • A WebForms 3 theme copy of MageMe_WebForms/web/css/form/form.less has no effect in WebForms 4. Move its rules into form-theme.less.
  • CSS in a CMS block, or in a stylesheet loaded in the page <head>, comes before the form's inline styles and loses on equal weight.

Troubleshooting​

  • The store still shows the module's template. Check that the folder is MageMe_WebForms/templates/ (on Hyvä too) and that the path below templates/ matches the module's exactly. Clean the cache and check which theme the store view uses.
  • On Hyvä the form lost its widgets or validation. You copied the core template. Copy the companion's template from Hyva_MageMeWebForms instead.
  • The form works on its page but not in a popup or the slide-out. Your template probably prints a <script>. Run bin/magento webforms:report templates and move the code out of the template.
  • The page source shows the Product Options form as a <form> inside the add-to-cart form. A copy of form/element/form.phtml, form/multistep/form.phtml or form/default.phtml in your theme prints the tag itself. Take over the module's $_inline branches, as described under Limits.
  • form-theme.less rules don't apply. Check the path MageMe_WebForms/web/css/form-theme.less. Then delete the processed copy and clean the full page cache, as in step 3 of Add CSS through the theme stylesheet: a cache clean alone keeps the old copy. If the rules still don't appear, check the LESS syntax of the file, for example a variable of your theme: an error drops the whole file and shows nowhere. On Hyvä the file isn't used.

What's next​

  • Styling contract: the attributes and tokens to write CSS against.
  • Frontend APIs: hook into the form from JavaScript instead of a template.
  • Settings: Frontend: the Hyvä Theme CSS Classes that change the companion's Tailwind classes without a template copy, and Fetch Slide-Out Form on First Open.

Applies to WebForms 4Last reviewed November 24, 2026