Skip to content

Commit

Permalink
Merge pull request #8 from ILDaviz/main
Browse files Browse the repository at this point in the history
Add filament 3.x support.
  • Loading branch information
AbanoubNassem authored Aug 20, 2023
2 parents 567b9e5 + 6bceb7e commit 4f9a070
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
}
],
"require": {
"php": "^8.0|^8.1",
"php": "^8.0|^8.1|^8.2",
"anhskohbo/no-captcha": "^3.4",
"filament/forms": "^2.16",
"filament/forms": "^2.16|^3.0-stable",
"illuminate/contracts": "^9.0|^10.0",
"spatie/laravel-package-tools": "^1.13.0"
},
Expand Down
9 changes: 4 additions & 5 deletions resources/views/forms/components/g-recaptcha.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

<script>
document.addEventListener('livewire:load', function () {
@this.
on('resetCaptcha', () => window.grecaptcha.reset())
@this.on('resetCaptcha', () => window.grecaptcha.reset())
});
var recaptchaCallback = () => window.Livewire.find('{{$this->id}}')
var recaptchaCallback = () => window.Livewire.find('{{ method_exists($this, 'id') ? $this->id(): $this->id }}')
.set('{{$getStatePath()}}', window.grecaptcha.getResponse(), true);
</script>

<x-dynamic-component
:component="$getFieldWrapperView()"
:field="method_exists($this, 'id') ? $field : null"
:component="$getFieldWrapperView()"
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-action="$getHintAction()"
:hint-color="$getHintColor()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
Expand All @@ -38,4 +38,3 @@
{!! NoCaptcha::display(['data-callback' => 'recaptchaCallback']) !!}
</div>
</x-dynamic-component>

6 changes: 5 additions & 1 deletion src/Forms/Components/GRecaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public function callAfterStateUpdated(): static
{
parent::callAfterStateUpdated();

$this->getLivewire()->emit('resetCaptcha');
if (method_exists($this->getLivewire(), 'dispatchFormEvent')) {
$this->getLivewire()->dispatchFormEvent('resetCaptcha');
} else {
$this->getLivewire()->emit('resetCaptcha');
}

return $this;
}
Expand Down

0 comments on commit 4f9a070

Please sign in to comment.