AbanoubNassem / filament-grecaptcha-field

Provides a Google reCaptcha V2 field for the Filament Forms(V2-V3), works in Admin-Panel and Forntend-Forms.
MIT License
18 stars 7 forks source link

Problems implementing recaptcha into breezy register #1

Closed imClement closed 1 year ago

imClement commented 1 year ago

Hi,

I am trying to implement recaptcha into the Register form of https://github.com/jeffgreco13/filament-breezy

While the ReCaptcha is displayed correctly and checked (green) I get "The field is required." after submit.

Any suggestion is appreciated.

Thank you,

AbanoubNassem commented 1 year ago

can you please share the code, where you include the ReCaptcha with? or a repo where I can test it?

imClement commented 1 year ago

Thank you for the quick reply.

Per package instructions I created app/Http/Livewire/Auth/Register.php


namespace App\Http\Livewire\Auth;

use AbanoubNassem\FilamentGRecaptchaField\Forms\Components\GRecaptcha;
use JeffGreco13\FilamentBreezy\Http\Livewire\Auth\Register as FilamentBreezyRegister;

class Register extends FilamentBreezyRegister
{
    // Define the new attributes
    public $captcha;

    // Override the getFormSchema method and merge the default fields then add your own.
    protected function getFormSchema(): array
    {
        return array_merge(parent::getFormSchema(),[
            GRecaptcha::make('captcha')
        ]);
    }

    // Use this method to modify the preparedData before the register() method is called.
    protected function prepareModelData($data): array
    {
        $preparedData = parent::prepareModelData($data);
        $preparedData['captcha'] = $this->captcha;

        return $preparedData;
    }

}

The ReCaptcha is correctly displayed in the register form and is is working by presenting challenges and allow me to solve it.

The problem is when I click the Register button the form return "The field is required." under the Recaptcha field.

im-Clement commented 1 year ago

Here is the vendor class that is extended by the above file:

https://github.com/jeffgreco13/filament-breezy/blob/1.x/src/Http/Livewire/Auth/Register.php

AbanoubNassem commented 1 year ago

@im-Clement @imClement

please update to version 0.0.3, and make sure that

    // Define the new attributes
    public $captcha = '' ;

the captcha property is initialized .

please test , and let me know if it works, thank you.

imClement commented 1 year ago

It works.

Thank you very much for the quick and effective reaction.