templates/pages/blocks/sub-blocks/project-form.html.twig line 1

Open in your IDE?
  1. <form class="{{class}} fade" action="{{ path }}" method="{{method}}" enctype="multipart/form-data">
  2.     {% for item in snippets %}
  3.         {% for form in item.form %}
  4.             {% for row in form.field %}
  5.                 
  6.                 {{ include('pages/blocks/form/' ~ row.type ~ '.html.twig', {
  7.                     content : row,
  8.                     index : loop.index
  9.                 }) }}
  10.             {% endfor %}
  11.         {% endfor %}
  12.     {% endfor %}
  13.     <input type="hidden" name="recaptchakey" value="6LfHlxIrAAAAAHU0zZg_LH6kRtAYpqWqv_gzVdsU">
  14.     <input id="recaptchaResponse" type="hidden" name="g-recaptcha-response"/>
  15.     <input type="hidden" name="referer" value="{{app.request.uri}}"/>
  16.     <input type="hidden" name="email-from" value="{{snippets ? snippets[0].submition_from : '' }}"/>
  17.     <input type="hidden" name="email-to" value="{{snippets ? snippets[0].submition_to : '' }}"/>
  18.     <input type="hidden" name="email-subject" value="{{snippets ? snippets[0].submition_subject : '' }}"/>
  19. </form>
  20. <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
  21. <script>
  22. $(document).ready(function() {
  23.     // Get the public key from the hidden input
  24.     var recaptchaKey = $('input[name="recaptchakey"]').val();
  25.     
  26.     // Check if the key exists
  27.     if (recaptchaKey) {
  28.         // Load the reCAPTCHA API script dynamically
  29.         $.getScript('https://www.google.com/recaptcha/api.js?render=' + recaptchaKey, function() {
  30.             // Once the script is loaded, execute reCAPTCHA
  31.             grecaptcha.ready(function() {
  32.                 grecaptcha.execute(recaptchaKey, {action: 'submit'}).then(function(token) {
  33.                     // Set the token in the g-recaptcha-response input
  34.                     $('#recaptchaResponse').val(token);
  35.                     console.log('reCAPTCHA token generated and set successfully');
  36.                 });
  37.             });
  38.         });
  39.     } else {
  40.         console.error('reCAPTCHA key not found');
  41.     }
  42. });
  43. </script>