Skip to content

Document adding custom validation rules for form fields #5

Description

@jamesmacwhite

As the previous plugin used the Craft Contact Form as base, you would implement custom validation rules like this:

use craft\contactform\Models\Submission;

Event::on(
    Submission::class,
    Model::EVENT_DEFINE_RULES,
    static function (DefineRulesEvent $event) {
        $event->rules[] = [['fromName', 'fromEmail', 'subject', 'message'], 'required'];
    }
);

As the plugin no longer uses the Craft Contact form, the namespace would now be: hybridinteractive\SimpleContactForm\Models\Submission;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions