in system.xml:
<field id="custom_field" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Custom Field</label>
<source_model>Vendor\Module\Block\Adminhtml\System\Config\Custom</source_model>
</field>
Custom.php:
namespace Vendor\Module\Block\Adminhtml\System\Config;
use Magento\Framework\App\Config\ScopeConfigInterface;
class Custom extends \Magento\Config\Block\System\Config\Form\Field
{
protected $_template = 'Vendor_Module::system/config/custom.phtml';
const TEMPLATE = 'Vendor_Module::system/config/custom.phtml';
protected $_moduleManager;
/**
*
* @param \Magento\Backend\Block\Template\Context $context
* @param ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\Framework\ObjectManagerInterface $objectmanager
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Module\Manager $moduleManager,
array $data = []
)
{
$this->_scopeConfig = $scopeConfig;
$this->_moduleManager = $moduleManager;
parent::__construct($context, $data);
}
/**
*
* @return $this
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
if (!$this->getTemplate()) {
$this->setTemplate(static::TEMPLATE);
}
return $this;
}
/**
* Retrieve element HTML markup.
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
*
* @return string
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$this->setNamePrefix($element->getName())
->setHtmlId($element->getHtmlId());
return $this->_toHtml();
}
}
custom.phtml: As an example but more then that basically any html element
<div class="test">
<p>
Click <a href="#">here</a>
</p>
</div>
<select name="custom" class="select admin__control-select"
data-ui-id="select-groups-third-fields-custom-value">
<option value="no">No</option>
<option value="yes">Yes</option>
</select>
<input type="checkbox" name="test" />
<p>END</p>