{% extends "forms/field.html.twig" %} {% block label %}{% endblock %} {% block input %} {% set config = grav.config %} {% set formId = form.id ?: form.name %} {# Get configuration values with fallbacks #} {% set site_key = field.turnstile_site_key ?? config.plugins.form.turnstile.site_key %} {% set theme = field.turnstile_theme ?? config.plugins.form.turnstile.theme ?? 'light' %} {% set container_id = 'cf-turnstile-' ~ formId %} {% set init_var = 'turnstile_initialized_' ~ formId %} {% if not site_key %}
Turnstile site key is not set. Please set it in the form field or plugin configuration.
{% else %} {# Add a hidden field for the token directly in the INPUT block to ensure it's part of the field #}
{% do assets.addJs('https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback_' ~ formId ~ '&render=explicit', { 'loading': 'async', 'defer': '' }) %} {% endif %} {% endblock %}