Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

enable_recaptcha(accepted values: true, skip_js)
Inserts an invisible Captcha (Google reCaptcha v3) inside the form, to prevent the form being used for spam. Set the value to 'true' for a regular implementation. If you need to handle the Captcha token generation yourself, set the value to 'skip_js'. Read the tutorial to learn how to do this. 

...

Note2 You need to add {% include "recaptcha_scripts" %} somewhere on the page that has the form on it. The form will not be submitted if the scripts are not included on the page! (go to docs about the include tag)

Examples

Input:

Code Block
{% form for: form, to: form.email, success_url: form.success_page_link %}
  {% for field in form.field_lines %}
    {% include field %}
  {% endfor %}
  <div>
    <input type="submit" >
  </div>
{% endform %}

...

Inside the 'form' block, you have access to the 'submitted_form_fields' object. This is a liquid object, representing all the (non-file) fields that were submitted. This allows you to keep your form fields filled when a validation error occurred.

...

Code Block
{% form ... %}
    {% for field in form.fields %}
        <input type="{{field.type}}" name="{{field.name | form_input_name}}" value="{{submitted_form_fields[field.name]}}"/>
        {% register_form_field field.name %}
    {% endfor %}
{% endform %}

By setting the value of the input field to the value in the 'submitted_form_fields' object, this input field will retain its value when the form is rendered again after a validation error on submitting the form.