RyanDaDeng / laravel-google-recaptcha-v3

It's probably the best Laravel Package for Google reCAPTCHA v3. Vue component supported.
MIT License
275 stars 40 forks source link

Usage with Livewire #91

Open titantwentyone opened 2 years ago

titantwentyone commented 2 years ago

Thank you for creating this package. I am hoping to use this within a Livewire component and wondering whether there are any special considerations to take into account.

My use case is with a registration form. In my Livewire components blade file, I have:

<div>
    @push('footer-scripts')
    {!!  GoogleReCaptchaV3::init() !!}
    @endpush

    <form wire:submit.prevent="submit">
        {!!  GoogleReCaptchaV3::renderField('registration_id','registration') !!}

        <label class='text-white mb-2'>Name(*)</label>
        <input type="text" name="name" class='si_field' wire:model="name">

        {{-- remainder of registration fields here--}}

        <button>Submit</button>

    </form>
</div>

When the above is rendered, I can see the scripts from the package render (functions refreshReCaptchaV3(fieldId,action) and getReCaptchaV3Response(fieldId) but there is no entry for the api js from Google (i.e. -) and the badge does not display.

Any pointers on the best way to use this package with Livewire? Apologies in advance if I have missed something very obvious!