Skip to content

Commit

Permalink
Render captcha script directly in the view
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Aug 2, 2021
1 parent 2cc1ebf commit eefea6b
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 58 deletions.
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,6 @@ Add the Livewire `styles` in the `head`, and the `scripts` before the closing `b
</body>
```

If you want to use `Google reCAPTCHA v2` you also need to add the captcha scripts before the closing `body` tag in your template.

```html
<body>
<!-- Antlers -->
{{ captcha:scripts }}

<!-- Blade -->
@captchaScripts
</body>
```

### 3. Create a Livewire form view

Run the following command and follow the instructions to create a Livewire view for your Statamic form. The form view will be published to `views/livewire/forms/my-form-handle.{antlers.html|blade.php}`.
Expand Down
4 changes: 2 additions & 2 deletions resources/views/captcha/captcha.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function resetResponseToken_{{ $_instance->id }}() {
}
</script>

@section('captchaScripts')
@once
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
@endsection
@endonce

@endif
1 change: 0 additions & 1 deletion resources/views/captcha/scripts.blade.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/BladeDirectives.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@

class BladeDirectives
{
/**
* Get the rendered captcha scripts view.
*/
public static function captchaScripts(): string
{
return '{!! \Aerni\LivewireForms\Facades\Captcha::scripts() !!}';
}

/**
* Get the captcha's key.
*/
Expand Down
8 changes: 0 additions & 8 deletions src/Captcha/ReCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ public function secret(): string
return config('livewire-forms.captcha.secret');
}

/**
* Render the captcha's scripts view.
*/
public function scripts()
{
return view('livewire-forms::scripts')->render();
}

/**
* Get the URL that's used to verify the captcha.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class ServiceProvider extends AddonServiceProvider
protected $tags = [
Tags\LivewireForms::class,
Tags\Iterate::class,
Tags\Captcha::class,
];

public function boot()
Expand Down Expand Up @@ -59,7 +58,6 @@ protected function registerPublishables()

protected function registerBladeDirectives()
{
Blade::directive('captchaScripts', [BladeDirectives::class, 'captchaScripts']);
Blade::directive('captchaKey', [BladeDirectives::class, 'captchaKey']);
}

Expand Down
25 changes: 0 additions & 25 deletions src/Tags/Captcha.php

This file was deleted.

0 comments on commit eefea6b

Please sign in to comment.