templates/Public/Public/contact.ajax.twig line 1

Open in your IDE?
  1. {%- trans_default_domain 'PublicBundle' -%}
    
    {{ form_start(form) }}
        <div class="row">
            <div class="col-5">
                {{ form_row(form.name, { 'label': false, 'attr': { 'placeholder': ('contact.form.name'|trans) } }) }}
                {{ form_row(form.email, { 'label': false, 'attr': { 'placeholder': ('contact.form.email'|trans) } }) }}
                {{ form_row(form.title, { 'label': false, 'attr': { 'placeholder': ('contact.form.title'|trans) } }) }}
            </div>
            <div class="col-7">
                {{ form_row(form.message, { 'label': false, 'attr': { 'placeholder': ('contact.form.message'|trans), 'rows': 6 } }) }}
    
                <button class="btn btn-primary btn-sm float-right btn-arrow" type="submit">
                    {{ 'contact.form.send'|trans }}
                    <span class="icon fa fa-angle-right"></span>
                </button>
            </div>
        </div>
    {{ form_rest(form) }}
    <script src="https://www.google.com/recaptcha/api.js?render={{ google.recaptcha.site_key }}"></script>
    <script>
        grecaptcha.ready(function() {
            grecaptcha.execute('{{ google.recaptcha.site_key }}', {action: 'homepage'}).then(function(token) {
                // ...
            });
        });
    
        // $('#comment_form').submit(function() {
        //     // we stoped it
        //     event.preventDefault();
        //     var email = $('#email').val();
        //     var comment = $("#comment").val();
        //     // needs for recaptacha ready
        //     grecaptcha.ready(function() {
        //         // do request for recaptcha token
        //         // response is promise with passed token
        //         grecaptcha.execute('put your site key here', {action: 'create_comment'}).then(function(token) {
        //             // add token to form
        //             $('#comment_form').prepend('<input type="hidden" name="g-recaptcha-response" value="' + token + '">');
        //             $.post("form.php",{email: email, comment: comment, token: token}, function(result) {
        //                 console.log(result);
        //                 if(result.success) {
        //                     alert('Thanks for posting comment.')
        //                 } else {
        //                     alert('You are spammer ! Get the @$%K out.')
        //                 }
        //             });
        //         });;
        //     });
        // });
    </script>