diff --git a/src/SuperTable.php b/src/SuperTable.php index 85825a1..c4d25bc 100755 --- a/src/SuperTable.php +++ b/src/SuperTable.php @@ -8,8 +8,10 @@ use Craft; use craft\base\Plugin; +use craft\events\DefineCompatibleFieldTypesEvent; use craft\events\RegisterComponentTypesEvent; use craft\events\RegisterUrlRulesEvent; +use craft\fields\Matrix; use craft\helpers\UrlHelper; use craft\services\Elements; use craft\services\Fields; @@ -45,6 +47,7 @@ public function init(): void $this->_registerVariables(); $this->_registerFieldTypes(); $this->_registerElementTypes(); + $this->_registerCompatibleFieldTypes(); } @@ -72,4 +75,13 @@ private function _registerElementTypes(): void }); } + private function _registerCompatibleFieldTypes(): void + { + Event::on(Fields::class, Fields::EVENT_DEFINE_COMPATIBLE_FIELD_TYPES, function(DefineCompatibleFieldTypesEvent $event) { + if (is_a($event->field, SuperTableField::class)) { + $event->compatibleTypes[] = Matrix::class; + } + }); + } + }