I'm trying to use the addComplexSuccessMessage function on admin custom module, but I get an empty message.
The code I have is the following:
/etc/di.xml
<!-- Admin HTML Complex Messages -->
<type name="Magento\Framework\View\Element\Message\MessageConfigurationsPool">
<arguments>
<argument name="configurationsMap" xsi:type="array">
<item name="createDocumentSuccessMessage" xsi:type="array">
<item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item>
<item name="data" xsi:type="array">
<item name="template" xsi:type="string">Invoicing_Moloni::messages/createDocumentSuccessMessage.phtml</item>
</item>
</item>
</argument>
</arguments>
</type>
view/adminhtml/templates/messages/createDocumentSuccessMessage.phtml
<?php
// @codingStandardsIgnoreFile
/** @var \Magento\Framework\View\Element\Template $block */
?>
<?= $block->escapeHtml(__(
'Document was sucessefuly created: <a href="%1">Open document</a>.',
$block->getData('document_url')),
['a']
);
Controller/Adminhtml/Documents/Create.php
$this->messageManager->addComplexSuccessMessage(
'createDocumentSuccessMessage',
[
'document_url' => $this->_url->getUrl('document/url')
]
);
I can't seem to understand why I get this empty message:
If anyone could help, I would really appreciate