Class \Magento\Framework\Data\Form\Element\AbstractElement
has the methods getBeforeElementHtml
and getAfterElementHtml
which are supposed to be used to add an arbitrary html before and after the form element.
The class \Magento\Framework\Data\Form\Element\Textarea
calls getAfterElementHtml
but does not call getBeforeElementHtml
:
I temporary fixed it for myself with a plugin:
<type name='Magento\Framework\Data\Form\Element\Textarea'>
<plugin
name='Df\Framework\Data\Form\Element\TextareaPlugin'
type='Df\Framework\Data\Form\Element\TextareaPlugin'
/>
</type>
<?php
namespace Df\Framework\Data\Form\Element;
use Magento\Framework\Data\Form\Element\Textarea;
class TextareaPlugin {
/**
* @see \Magento\Framework\Data\Form\Element\Textarea::getElementHtml()
* @param Textarea $subject
* @param string $result
* @return string
*/
public function afterGetElementHtml(Textarea $subject, $result) {
/** @var string $before */
$before = $subject->getBeforeElementHtml();
if (0 !== strpos($result, $before)) {
$result = $before . $result;
}
return $result;
}
}