District Core Developer DocsDistrict Core Developer Docs
Developers
Boilerplate
Modules
Bitbucket
Developers
Boilerplate
Modules
Bitbucket
  • Modules

    • ABN
    • ActivityLog
    • AnalyticsApi
    • ApiConnector
    • BlockApi
    • CategoryApi
    • CloneApi
    • CommentApi
    • ContentApi
    • Core
    • Documents
    • EmbedApi
    • Event
    • ExportApi
    • FeatureApi
    • FormApi
    • GTM
    • GalleryApi
    • HelpApi
    • Hotspot
    • IdeaSurvey
    • ImportApi
    • InteractionsApi
    • Intercom
    • MailApi
    • MapApi
    • MapSurvey
    • MediaApi
    • MenuApi
    • MetaTagApi
    • NlpApi
    • NotificationApi
    • Page
    • ParentableContent
    • PaymentApi
    • PermissionsApi
    • Postcode
    • ReCaptcha
    • Redirects
    • Renderer
    • ReportApi
    • RestrictionApi
    • RevisionApi
    • SearchApi
    • Settings
    • ShareableApi
    • Slack
    • SlugApi
    • SubscribableApi
    • Survey
    • Team
    • TenantApi
    • TestApi
    • ThemeApi
    • Timeline
    • TranslationApi
    • Update
    • Users
    • VisualisationApi
    • WorkflowApi
    • Wysiwyg

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.


Edit this page
Prev
Postcode
Next
Redirects