Skip to content

Commit

Permalink
Fixed widget not showing on third party form
Browse files Browse the repository at this point in the history
  • Loading branch information
magentix committed Jun 26, 2023
1 parent 64c6208 commit 493639a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ Override the default action name by adding an action option:
1. Add the Cloudflare Turnstile widget in the Smarty form template:

```html
{widget name='pixel_cloudflare_turnstile' action='custom-form'}
{widget name='pixel_cloudflare_turnstile' custom='1' action='custom-form'}
```

**Note:** The action param is a free name that will appear in the Turnstile statistics

2. In a module, add a new hook to call Turnstile validation on form post:

```php
Expand Down
5 changes: 3 additions & 2 deletions pixel_cloudflare_turnstile.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Pixel_cloudflare_turnstile extends Module implements WidgetInterface
public function __construct()
{
$this->name = 'pixel_cloudflare_turnstile';
$this->version = '1.1.2';
$this->version = '1.1.3';
$this->author = 'Pixel Open';
$this->tab = 'front_office_features';
$this->need_instance = 0;
Expand Down Expand Up @@ -367,7 +367,8 @@ protected static function getErrorMessage(string $code): string
public function renderWidget($hookName, array $configuration): string
{
$className = get_class($this->context->controller);
if (!$this->canProcess($className)) {
$isCustom = (int)($configuration['custom'] ?? 0) === 1;
if (!$isCustom && !$this->canProcess($className)) {
return '';
}
$keys = [$this->name, $className, $this->getFormName()];
Expand Down

0 comments on commit 493639a

Please sign in to comment.