It would be cool if plugins/modules could bring their own custom field UI elements - could we get an event right here, please?
https://github.com/craftcms/cms/blob/10c476aedfecd32c9f8d7d426722f5ea5ec8f6b0/src/models/FieldLayout.php#L238-L250
Yeah will think about this, but I think the Template UI element is going to generally be a better solution.
@brandonkelly the template UI element cannot store settings (unless you overwrite it). In case someone wishes to have different options an event is a better solution.
Imagine the headline wouldn't have the ability to store a string/message and you would have to create a different template for each headline/hint/warning.
If there was an event I would instantly convert several custom fields that exists only for displaying purpose into ui elements.
Forgot about this request, but we added a new event for defining custom UI elements in Craft 3.5 RC5!
use craft\models\FieldLayout;
use craft\events\DefineFieldLayoutElementsEvent;
use yii\base\Event;
Event::on(
FieldLayout::class,
FieldLayout::EVENT_DEFINE_UI_ELEMENTS,
function(DefineFieldLayoutElementsEvent $event) {
$event->elements[] = MyUiElement::class;
}
);
Recommend extending BaseUiElement as that will take care of a lot of the leg work for you. Examples:
Most helpful comment
Forgot about this request, but we added a new event for defining custom UI elements in Craft 3.5 RC5!
Recommend extending BaseUiElement as that will take care of a lot of the leg work for you. Examples: