Use existing TCA fields¶
If you want to use already existing TCA fields, beyond the core fields, you can
use an EventListener to modify the $allowedFields
array.
EventListener example¶
<?php
declare(strict_types=1);
namespace VENDOR\SomeExtension\EventListener;
use MASK\Mask\Event\MaskAllowedFieldsEvent;
class MaskAllowedFieldsEventListener
{
public function __invoke(MaskAllowedFieldsEvent $event): void
{
// Add field
$event->addField('teaser');
// Remove field
$event->removeField('imagecols');
// Get all allowed fields
$allowedFields = $event->getAllowedFields();
// Do your magic and set allowed fields
$event->setAllowedFields($allowedFields);
}
}
Copied!
Register EventListener¶
services:
VENDOR\Extension\EventListener\MaskAllowedFieldsEventListener:
tags:
- name: event.listener
identifier: 'customizeAllowedFields'
event: MASK\Mask\Event\MaskAllowedFieldsEvent
Copied!
Have a look at the official documentation for more information.