In admin form, I created custom field type and then, add html content by custom phtml file.
But, after that label not display with custom field type.
Custom Field Type :
$fieldset->addType(
'custom_field_labels',
'\Vendor\Magento\Block\Adminhtml\Module\Edit\Renderer\CustomField'
);
$fieldset->addField(
'custom_text',
'custom_field_labels',
[
'name' => 'custom_text',
'label' => __('Custom Text'),
'title' => __('Custom Text'),
]
);
Vendor\Magento\Block\Adminhtml\Module\Edit\Renderer\CustomField.php
<?php
namespace Vendor\Magento\Block\Adminhtml\Module\Edit\Renderer;
class CustomField extends \Magento\Framework\Data\Form\Element\AbstractElement {
protected $_blockFactory;
public function __construct(
\Magento\Framework\View\Element\BlockFactory $_blockFactory
) {
$this->_blockFactory = $_blockFactory;
}
/**
* Get the after element html.
*
* @return mixed
*/
public function getElementHtml() {
$customDiv = $this->_blockFactory
->createBlock('Vendor\Magento\Block\Adminhtml\Module\Edit\Tabs\MyTab')
->setTemplate('Vendor_Magento::product/tabs/mytabs.phtml')->toHtml();
return $customDiv;
}
}
How can I solve that issue?
Any help would be appreciated.