Embed Form in XML Layout

You can call any web-form in layout using following code sample:

Default form widget

<block class="VladimirPopov\WebForms\Block\Form" template="VladimirPopov_WebForms::webforms/form/default.phtml">
<arguments>
<argument name="webform_id" xsi:type="string">1</argument>
<argument name="scroll_to" xsi:type="string">0</argument>
<argument name="after_submission_form" xsi:type="string">0</argument>
<argument name="async_load" xsi:type="string">1</argument>
</arguments>
</block>

webform_id - is actual ID of the form.

template - form template which can have following values:

  • webforms/form/default.phtml - default template
  • webforms/form/multistep.phtml - multi-step template
  • webforms/form/sidebar.phtm - compact sidebar template very similar to default

after_submission_form - show form after submission and display success text in popup.

scroll_to - scroll to the top of the success message after form submission.

async_load - load form asynchronously to bypass any caching. This is recommended when you pre-fill fields with customer data.

Button with the form in popup

<block class="VladimirPopov\WebForms\Block\Widget\Button" template="VladimirPopov_WebForms::webforms/button/default.phtml">
<arguments>
<argument name="webform_id" xsi:type="string">1</argument>
<argument name="form_template" xsi:type="string">webforms/form/default.phtml</argument>
<argument name="button_text" xsi:type="string">Show form</argument>
<argument name="scroll_to" xsi:type="string">0</argument>
<argument name="after_submission_form" xsi:type="string">0</argument>
<argument name="async_load" xsi:type="string">1</argument>
</arguments>
</block>

webform_id - is actual ID of the form.

template - form template which can have following values:

  • webforms/button/default.phtml - default template

form_template - form template which can have following values:

  • webforms/form/default.phtml - default template
  • webforms/form/multistep.phtml - multi-step template
  • webforms/form/sidebar.phtm - compact sidebar template very similar to default

after_submission_form - show form after submission and display success text in popup.

button_text - text on the button.

scroll_to - scroll to the top of the success message after form submission.

async_load - load form asynchronously to bypass any caching. This is recommended when you pre-fill fields with customer data.

note

Please note that template and form_template have different values. In case of the button the first one renders the button with popup script, the second one - form.