fix: recaptcha contact
This commit is contained in:
parent
6cd6c0700a
commit
d84e28d8bc
4 changed files with 65 additions and 19 deletions
|
|
@ -37,6 +37,11 @@ return [
|
|||
|
||||
'google' => [
|
||||
'maps' => env('GOOGLE_MAPS_KEY'),
|
||||
'recaptcha' => [
|
||||
'public' => env('GOOGLE_RECAPTCHA_PUBLIC'),
|
||||
'private' => env('GOOGLE_RECAPTCHA_PRIVATE'),
|
||||
'version' => env('GOOGLE_RECAPTCHA_VERSION', "3") === "3" ? true : false
|
||||
]
|
||||
],
|
||||
|
||||
'matomo' => [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
@push('scripts')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const formId = @json($formId);
|
||||
const initFormCaptcha = () => {
|
||||
const newDiv = document.createElement("div");
|
||||
newDiv.classList.add('g-recaptcha');
|
||||
document.getElementById('r_captcha').appendChild(newDiv);
|
||||
};
|
||||
window.__CN_Recaptcha = function() {
|
||||
initFormCaptcha();
|
||||
(function(d, t) {
|
||||
let g = d.createElement(t),
|
||||
s = d.getElementsByTagName(t)[0];
|
||||
g.src =
|
||||
'https://www.google.com/recaptcha/api.js?render=explicit&onload=__CN_Recaptcha_Loaded';
|
||||
s.parentNode.insertBefore(g, s)
|
||||
}(document, 'script'));
|
||||
};
|
||||
window.__CN_Recaptcha_Reset = function() {
|
||||
document.querySelector('#r_captcha > div')?.remove();
|
||||
};
|
||||
window.__CN_Recaptcha_Loaded = function() {
|
||||
grecaptcha.render(document.querySelector('#r_captcha > div'), {
|
||||
'sitekey': '{{ config('services.google.recaptcha.public') }}'
|
||||
});
|
||||
};
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -1,29 +1,37 @@
|
|||
|
||||
<div class="form__row">
|
||||
@if (\App\Enums\Contact\ContactFormType::press->equals($contactFormType))
|
||||
<div class="form__field">
|
||||
<label class="form__field-pseudolabel">
|
||||
<input type="checkbox" name="newsletter" value="1">
|
||||
<span class="form__field-pseudosquare">{{ __('front.inputs.newsletter.label') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
<div class="form__row">
|
||||
@if (\App\Enums\Contact\ContactFormType::press->equals($contactFormType))
|
||||
<div class="form__field">
|
||||
<span class="form__field-label-text">{{ __('front.contact.info_personal_data') }}
|
||||
<br> <a href="/politique-de-confidentialite/" target="_blank"
|
||||
rel="noreferer noopener">{{ __('front.contact.confidentiality') }}</a></span>
|
||||
<label class="form__field-pseudolabel">
|
||||
<input type="checkbox" name="newsletter" value="1">
|
||||
<span class="form__field-pseudosquare">{{ __('front.inputs.newsletter.label') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="form__field">
|
||||
<div class="form__tip">* {{ ucfirst(__('front.required_field')) }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form__field">
|
||||
<span class="form__field-label-text">{{ __('front.contact.info_personal_data') }}
|
||||
<br> <a href="/politique-de-confidentialite/" target="_blank"
|
||||
rel="noreferer noopener">{{ __('front.contact.confidentiality') }}</a></span>
|
||||
</div>
|
||||
|
||||
<div class="form__field">
|
||||
<div class="form__tip">* {{ ucfirst(__('front.required_field')) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- RECAPTCHA --}}
|
||||
<div>
|
||||
<div id="r_captcha"></div>
|
||||
@if ($errors->has('g-recaptcha-response'))
|
||||
<div>
|
||||
<span>{{ $errors->first('g-recaptcha-response') }}</span>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="form__row">
|
||||
<div class="form-submit">
|
||||
<input type="submit" value="{{ ucfirst(__('front.buttons.send')) }}" class="form-submit__btn btn">
|
||||
<input data-sitekey="{{ config('services.google.recaptcha.public') }}" type="submit" value="{{ ucfirst(__('front.buttons.send')) }}" class="form-submit__btn btn">
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@
|
|||
@endif
|
||||
|
||||
@include('front.pages.contact.partials.form-footer')
|
||||
|
||||
</x-front.pages.contact.form-wrapper>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<x-front.pages.contact.contact-form-script formId="contact-form" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue