---
title: Events
date: 2026-06-12T22:27:00+01:00
author: John Henry Donovan
canonical_url: "https://johnhenry.ie/plugins/matrix-block-anchor/docs/api/events"
section: Plugins
---
esc

↑↓ to navigate↵ to selectesc to close

Menu On this page 

- [Return to top](#)

Documentation

Documentation

# Events

Matrix Block Anchor does not currently fire custom events. Standard Craft field events (`EVENT_DEFINE_RULES`, `EVENT_AFTER_VALIDATE`, etc.) apply as they do on any `craft\base\Field` subclass.

## Extending Validation

To add custom validation rules to the anchor field, use Craft's `EVENT_DEFINE_RULES` event on the field class:

```php
use craft\base\Field;
use craft\events\DefineRulesEvent;
use johnhenry\matrixblockanchor\fields\MatrixBlockAnchorField;
use yii\base\Event;

Event::on(
    MatrixBlockAnchorField::class,
    Field::EVENT_DEFINE_RULES,
    function (DefineRulesEvent $event) {
        $event->rules[] = ['handle', 'match', 'pattern' => '/^anchor/'];
    }
);
```

## Registering the Field Type

The field type is registered automatically when the plugin is installed. To reference the class in your own code:

```php
use johnhenry\matrixblockanchor\fields\MatrixBlockAnchorField;

$anchorFields = Craft::$app->getFields()->getFieldsByType(MatrixBlockAnchorField::class);
```

On this page
