My block file form.php and I want to call phtml file in this block to display table in this custom admin form, I have no created a layout for this phtml file, if is there any other way to display the table then also suggest me, Thanks
<?php
namespace Vendor\Module\Block\Adminhtml\Blog\Edit;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Registry;
use Magento\Framework\Data\FormFactory;
use Vendor\Module\Block\Adminhtml\Status;
class Form extends \Magento\Backend\Block\Widget\Form\Generic
{
protected $_systemStore;
protected $template;
public function __construct(
Context $context,
Registry $registry,
FormFactory $formFactory,
Status $options,
array $data = []
)
{
$this->options = $options;
parent::__construct($context, $registry, $formFactory, $data);
}
protected function _prepareForm()
{
$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
$model = $this->_coreRegistry->registry('row_data');
$form = $this->_formFactory->create(
['data' => [
'id' => 'edit_form',
'enctype' => 'multipart/form-data',
'action' => $this->getData('action'),
'method' => 'post'
]
]
);
$file1Url = $model->getFile1();
$file2Url = $model->getFile2();
$file3Url = $model->getFile3();
$form->setHtmlIdPrefix('mtgrid_');
if ($model->getId()) {
$fieldset = $form->addFieldset(
'base_fieldset',
['legend' => __('Edit Row Data'), 'class' => 'fieldset-wide']
);
$fieldset->addField('id', 'hidden', ['name' => 'id']);
} else {
$fieldset = $form->addFieldset(
'base_fieldset',
['legend' => __('Add Row Data'), 'class' => 'fieldset-wide']
);
}
$fieldset->addField(
'prapproveno',
'text',
[
'name' => 'prapproveno',
'label' => __('Prior Approve No.'),
'id' => 'prapproveno',
'title' => __('Prior Approve No.'),
'class' => '',
]
);
$fieldset->addField(
'submitdate',
'date',
[
'name' => 'submitdate',
'label' => __('Submit Date'),
'date_format' => $dateFormat,
'time_format' => 'HH:mm:ss',
'class' => 'validate-date validate-date-range date-range-custom_theme-from',
'class' => 'required-entry',
]
);
$fieldset->addField(
'chnlmanager',
'text',
[
'name' => 'chnlmanager',
'label' => __('Channel Maneger'),
'id' => 'chnlmanager',
'title' => __('Channel Manager'),
'class' => 'required-entry',
]
);
$fieldset->addField(
'status',
'select',
[
'name' => 'status',
'label' => __('Status'),
'id' => 'status',
'title' => __('Status'),
'values' => [1=>"Enable",0=>"Disable"],
'class' => 'status',
'required' => true,
]
);
$fieldset->addField(
'company',
'select',
[
'name' => 'company',
'label' => __('Company'),
'id' => 'company',
'title' => __('Company'),
'values' => $this->options->getOptionArray(),
'class' => 'required-entry',
'required' => true,
]
);
$fieldset->addField(
'branch',
'text',
[
'name' => 'branch',
'label' => __('Branch'),
'id' => 'branch',
'title' => __('Branch'),
'class' => 'required-entry',
]
);
$fieldset->addField(
'avpno',
'text',
[
'name' => 'avpno',
'label' => __('AVP/Reseller No.'),
'id' => 'avpno',
'title' => __('AVP/Reseller No.'),
'class' => 'required-entry',
]
);
$fieldset->addField(
'budgetfrom',
'select',
[
'name' => 'budgetfrom',
'label' => __('Budget From'),
'id' => 'budgetfrom',
'title' => __('Budget From'),
'values' => $this->options->getOptionArray(),
'class' => 'required-entry',
'required' => true,
]
);
$fieldset->addField(
'marketingactivity',
'select',
[
'name' => 'marketingactivity',
'label' => __('Marketing Activity'),
'id' => 'budgetfrom',
'title' => __('Budget From'),
'values' => $this->options->getOptionArray(),
'class' => 'required-entry',
'required' => true,
]
);
$fieldset->addField(
'description',
'text',
[
'name' => 'description',
'label' => __('Description'),
'id' => 'description',
'title' => __('Description'),
'class' => 'required-entry',
]
);
$fieldset->addField(
'file1',
'file',
[
'name' => 'file1',
'label' => __('Attachments'),
'id' => 'file1',
'title' => __('Attachments'),
'class' => '',
'note' => 'PDF format only',
'value'=>$file1Url
]
);
$fieldset->addField(
'file2',
'file',
[
'name' => 'file2',
'label' => __(''),
'id' => 'file2',
'title' => __(''),
'class' => '',
'note' => 'PDF format only',
'value'=>$file2Url
]
);
$fieldset->addField(
'file3',
'file',
[
'name' => 'file3',
'label' => __(''),
'id' => 'file3',
'title' => __(''),
'class' => '',
'note' => 'PDF format only',
'value'=>$file3Url
]
);
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}