I am trying to add an HTML snippet to my extension's config page.

I believe I need to create a block file and then reference this inside my extension's system.xml file using a <frontend_model> tag, but am unsure what to put in the block file.

If anyone knows how to do this then some basic example code would be appreciated!

1 Answer 1


Define frontend model to point to block logic

Something like this


you can append html with following ways

    <field id="test" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Some Test</label>
                        <comment><![CDATA[test contet]]></comment>


block code

    namespace Test\Module\Block;

    class Test extends \Magento\Config\Block\System\Config\Form\Field {

        public function __construct(
        \Magento\Backend\Block\Template\Context $context, array $data = []
        ) {
            parent::__construct($context, $data);

        protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) {
            $html = $element->getElementHtml();
            $value = $element->getData('value');

            $html .= 'use your logice here';
            return $html;


Easiest solution I can find

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Jarnail S
    Commented Sep 17, 2019 at 2:02
  • I assumed linked to within stack exchange was acceptable Commented Sep 17, 2019 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.