comvation / fusionform-hcaptcha
hCaptcha field and validator for Neos.Fusion.Form
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:neos-package
Requires
- neos/fusion-form: ~2.0 || dev-master || dev-main
- neos/neos: ^8.0 || ^9.0 || dev-master
README
Integrates the hCaptcha into any Neos.Fusion.Form.
Inspired by sitegeist/Sitegeist.FusionForm.FriendlyCaptcha.
Requirements
- Neos
- Composer
Supported and Tested Versions
Neos from 8.0 up to and including 9.0.x.
Installation
Add the plugin, and install the dependencies:
composer require comvation/fusionform-hcaptcha composer install
Usage
Add the captcha field and validator to your form content and schema, respectively:
prototype(Vendor.Site:RuntimeForm) < prototype(Neos.Fusion.Form:Runtime.RuntimeForm) {
process {
content = afx`
[...your form contents...]
<!-- field.name value MUST match the schema property below -->
<Neos.Fusion.Form:FieldContainer field.name="h-captcha-response">
<Comvation.FusionForm.HCaptcha:HCaptcha />
</Neos.Fusion.Form:FieldContainer>
`
schema {
[...your schema entries...]
<!-- This name must be equal to the field.name above -->
h-captcha-response = ${Form.Schema.string().isRequired()}
h-captcha-response.@process.captchaValidator = ${value.validator('Comvation.FusionForm.HCaptcha:HCaptcha')}
}
}
action { [no changes required] }
}
Add the key and secret, as well as other desired configuration to your Settings.yaml.
Note: Only a few selected configuration options are available in the settings for now.
Comvation: FusionForm: HCaptcha: siteKey: '<your-key>' siteSecret: '<your-secret>' size: 'invisible' # optional, default is "normal" theme: 'dark' # optional, default is "light"
See hCaptcha docs for details on the available options, as well as test keys.
Using a Custom Button
By default, the plugin presumes that the form uses a standard form submit button.
If that isn't the case, specify a selector attribute that exclusively matches your button.
For example, this one
footer = afx`
<button class="my-submit">Send</button>
`
may be used by adding the selector attribute
<Comvation.FusionForm.HCaptcha:HCaptcha
selector={'button[class=my-submit]'}
/>