Hi I need to get my custom module form data in getElementHtml(). Here is my form code:
$fieldset->addType(
'mycustomfield',
'MY\CustomModule\Block\Adminhtml\CustomModule\Renderer\Image'
);
$fieldset->addField(
'customdiv',
'mycustomfield',
[
'name' => 'customdiv',
'label' => __('Custom Div'),
'title' => __('Custom Div'),
]
);
And below are my Image.php
<?php
namespace MY\CustomModule\Block\Adminhtml\CustomModule\Renderer;
use Magento\Backend\App\Action;
class Image extends \Magento\Framework\Data\Form\Element\AbstractElement
{
public function getElementHtml()
{
$id = $this->getRequest()->getParam('custommodule_id');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$model = $objectManager->create('MY\CustomModule\Model\CustomModule');
$model->load($id);
return $model;
}
}
Did not get ID here. Even not able to create Objectmanage. If I return just normal string it's only working like.
return 'Test';
It's working but not getting any data. Can anyone see to get custom_module ID.
If I return $id OR $model then I get below error:
Item Information Changes have been made to this section that have not been saved. This tab contains invalid data. Please resolve this before saving.