0

I am trying to add a text block in Magento 2 system configuration group.
I want to write some hints for the users in a separate group. As it can be done in Magento 1.

Here is my screenshot what I actually want.

Magento 1.x System Configuration Group's Block

Still, I am waiting for any response. Is there anyone who has done this before in Magento 2?
Please let me know about this.

Thanks in Advance.

fmsthird
4,6224 gold badges18 silver badges42 bronze badges
asked Dec 30, 2016 at 9:47
1
  • Anyone found solution for this? Commented Jan 5, 2017 at 7:10

1 Answer 1

0

You can use the <frontend_model> feature of system configuration. here is the example

 <field id="YOUR_NAME" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="100">
 <frontend_model>VENDOR\MODULE_NAME\Block\Adminhtml\System\Config\Advanced</frontend_model>
 <attribute type="shared">1</attribute>
 </field>

and your block file should contain this code

<?php
namespace VENDOR\MODULE_NAME\Block\Adminhtml\System\Config;
class Advanced extends \Magento\Config\Block\System\Config\Form\Field
{
 /**
 * Template path
 *
 * @var string
 */
 protected $_template = 'system/config/advance/YOUR_FILE.phtml';
 /**
 * Render fieldset html
 *
 * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
 * @return string
 */
 public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
 {
 $columns = $this->getRequest()->getParam('website') || $this->getRequest()->getParam('store') ? 5 : 4;
 return $this->_decorateRowHtml($element, "<td colspan='{$columns}'>" . $this->toHtml() . '</td>');
 }
}

And in your view\adminhtml\templates\system\config\advance\YOUR_FILE.phtml file you can write anything which you want

<div>
<?php echo __('Hello WOrld'); ?>
</div>
Msquare
9,4627 gold badges30 silver badges71 bronze badges
answered Dec 30, 2016 at 10:19
9
  • Can you tell me where to keep this phtml file. Commented Dec 30, 2016 at 11:07
  • view\adminhtml\templates\system\config\advance\YOUR_FILE.phtml Commented Dec 30, 2016 at 11:11
  • Any reason @GauravAgrawal :) Commented Dec 30, 2016 at 13:53
  • Hey Keyur, I am not able to check your answer after implementation. because of some access issue. So whenever I will check and complete it. Will update here. Commented Dec 30, 2016 at 13:59
  • Hey Keyur, I have tried your solution today. And it not worked for me. It shows a black page after adding code provided by you. Commented Jan 2, 2017 at 7:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.