ReCaptcha module
This package provides a Vue Formulate component and a validator that can be used to add a recaptcha challenge to a form.
It uses vue-recaptcha under the hood.
Steps required
Add custom submit handler to form.
<template>
<custom-form-layout
...
@submit="recaptchaSubmit(submit)"
>
...
</custom-form-layout>
</template>
<script>
...
import ReCaptchaMixin from "~ReCaptcha/Mixins/ReCaptchaMixin";
export default {
...
mixins: [..., ReCaptchaMixin],
methods: {
submit(recaptchaToken) {
// Save the recaptcha response token to the form values.
this.form.recaptcha = recaptchaToken;
this.form
.post(...)
},
}
}
</script>
Add the recaptcha form element to the form schema.
$formschema = [
...
['type' => 'recaptcha', 'name' => 'recaptcha'],
...
];
Add the recaptcha validator to the backend validation.
Validator::make($input, [
...
'recaptcha' => 'recaptcha',
...
])->validate();
That's everything done.