The class \Magento\Framework\Data\Form\Element\Textarea breaks specification of the parent class \Magento\Framework\Data\Form\Element\AbstractElement by not calling the method getBeforeElementHtml (getAfterElementHtml is called)

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.

https://github.com/magento/magento2/blob/80c5e2b00170b290909f65f8922a7ebcb315ed1a/lib/internal/Magento/Framework/Data/Form/Element/AbstractElement.php#L385-L388

https://github.com/magento/magento2/blob/80c5e2b00170b290909f65f8922a7ebcb315ed1a/lib/internal/Magento/Framework/Data/Form/Element/AbstractElement.php#L395-L398

The class \Magento\Framework\Data\Form\Element\Textarea calls getAfterElementHtml but does not call getBeforeElementHtml:

https://github.com/magento/magento2/blob/80c5e2b00170b290909f65f8922a7ebcb315ed1a/lib/internal/Magento/Framework/Data/Form/Element/Textarea.php#L84-L88

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;
	}
}

https://github.com/magento/magento2/issues/2202

See also: