Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Captcha Value always gives invalid value #282

Open
aeq-dev opened this issue Feb 16, 2024 · 1 comment
Open

Captcha Value always gives invalid value #282

aeq-dev opened this issue Feb 16, 2024 · 1 comment

Comments

@aeq-dev
Copy link

aeq-dev commented Feb 16, 2024

Hello guys,
I'm trying to set the captcha on a form using livewire v3, I'm able to generate the image and refresh it, but every time I set the correct value, captcha gives me an invalid value.
Please anyone has used it with livewire V3 ?
Thanks

@spam-n-eggs
Copy link

spam-n-eggs commented May 3, 2024

@aeq-dev Take a look at how I implemented it in the Dominion Solutions Captcha plugin for Filament - I'm using Filament, but it's all on top of Livewire: https://github.com/dominion-solutions/filament-captcha. The key is properly entangling the state of the form: https://github.com/dominion-solutions/filament-captcha/blob/main/resources/views/form/components/captcha.blade.php. If you look at the top of the file you'll see:

<x-dynamic-component :component="$getFieldWrapperView()" :field="$field" :inline-label-vertical-alignment="\Filament\Support\Enums\VerticalAlignment::Center">
    <div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}').defer }">

This is all the "stuff" I'm using to bind the state of the field for validation.

Then in the actual form component I'm using:

public function form(Form $form): Form
{
    return $form->schema([
        Captcha::make('captcha')
            ->rules(['captcha'])
            ->required()
            ->validationMessages([
                'captcha'  =>  __('Captcha does not match the image'),
            ]),
        ]);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants