Skip to content

Commit

Permalink
Add support for Fields::EVENT_DEFINE_COMPATIBLE_FIELD_TYPES when co…
Browse files Browse the repository at this point in the history
…nverting to Matrix, to remove warning about changing Super Table to Matrix fields
  • Loading branch information
engram-design committed Apr 8, 2024
1 parent d402d62 commit 74e6ceb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/SuperTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,6 +47,7 @@ public function init(): void
$this->_registerVariables();
$this->_registerFieldTypes();
$this->_registerElementTypes();
$this->_registerCompatibleFieldTypes();
}


Expand Down Expand Up @@ -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;
}
});
}

}

0 comments on commit 74e6ceb

Please sign in to comment.