Custom Form Validation

Hello

Im trying to do some custom validation on a form, have made a plugin as per the Reference:Form Actions chapter in the documentation.

public static function getSubscribedEvents()
{
    return [
        'onFormProcessed' => ['onFormProcessed', 0]
    ];
}
public function onFormProcessed(Event $event)
{
    $form = $event['form'];
    $action = $event['action'];
    $params = $event['params'];

    switch ($action) {
        case 'uniqueUser':
        .
        . 
        .
}

This is called from form.md as:

process:
- validate: uniqueUser

This crashes with the following error:

“Argument 1 passed to Grav\Plugin\FormPlugin::onFormValidationError() must be an instance of Grav\Toolbox\Event\Event, instance of RocketTheme\Toolbox\Event\Event given”

What am I missing?

Please paste your code in triple backticks. I can’t make sense of this without your pasted content in code blocks.

Sorry, another try:

public static function getSubscribedEvents()

{

return [

‘onFormProcessed’ => ['onFormProcessed', 0]

];

}

public function onFormProcessed(Event $event)

{

$form = $event['form']; 

$action = $event['action'];

$params = $event['params'];

switch ($action) {

case ‘uniqueUser’:

.

.

.

}

This is called from form.md as:

process:

– validate: uniqueUser

This crashes with the following error:

“Argument 1 passed to Grav\Plugin\FormPlugin::onFormValidationError() must be an instance of Grav\Toolbox\Event\Event, instance of RocketTheme\Toolbox\Event\Event given