How to add phtml file at edit tab of Magento 2 custom module in admin?Add template file in admin edit formUse Custom HTML in Edit form Adminhtml magento 2How to configure custom admin module to show phtml fileHow can i rewrite TierPrice Block in Magento2Magento admin add grid under a tab in custom moduleI created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Magento 2.1.0 How to edit admin template of subitem grid of bundle productshow .phtml file in admin custom moduleError with Dependency Injection in widgetMagento 2 Add new field to Magento_User admin formMagento 2.3 Can't view module's front end page output?luma-theme .phtml file override in Custom Module
How to determine if an Apex class hasn't been used recently
Is there such a thing as too inconvenient?
Was 'help' pronounced starting with a vowel sound?
Sleeping solo in a double sleeping bag
A second course in the representation theory
How could China have extradited people for political reason under the extradition law it wanted to pass in Hong Kong?
Are illustrations in novels frowned upon?
Can pay be witheld for hours cleaning up after closing time?
To "hit home" in German
jersey vs sweater
Nuclear decay triggers
Was Tuvok bluffing when he said that Voyager's transporters rendered the Kazon weapons useless?
How to think about joining a company whose business I do not understand?
Is it safe to remove the bottom chords of a series of garage roof trusses?
How to persuade recruiters to send me the Job Description?
How does the government purchase things?
Why is 日本 read as "nihon" but not "nitsuhon"?
How big would a Daddy Longlegs Spider need to be to kill an average Human?
Was Switzerland really impossible to invade during WW2?
How to compare two different formulations of a problem?
Is refusing to concede in the face of an unstoppable Nexus combo punishable?
Are required indicators necessary for radio buttons?
The teacher logged me in as administrator for doing a short task, is the whole system now compromised?
What is the evidence on the danger of feeding whole blueberries and grapes to infants and toddlers?
How to add phtml file at edit tab of Magento 2 custom module in admin?
Add template file in admin edit formUse Custom HTML in Edit form Adminhtml magento 2How to configure custom admin module to show phtml fileHow can i rewrite TierPrice Block in Magento2Magento admin add grid under a tab in custom moduleI created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Magento 2.1.0 How to edit admin template of subitem grid of bundle productshow .phtml file in admin custom moduleError with Dependency Injection in widgetMagento 2 Add new field to Magento_User admin formMagento 2.3 Can't view module's front end page output?luma-theme .phtml file override in Custom Module
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have created a custom module. When we click on the admin grid to edit, it opens edit page. In that I am showing tabs. When I click on that tab I need to show template file. If you see the below screen you can get idea
this is my tab file
<?php
/**
/**
* Exinent_Customerids Module
*
* @category customer
* @package
* @author pawan
*
*/
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
/**
* customerid post edit form main tab
*/
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
// const IBAN_TEMPLATE = 'Exinent_Customerids::test.phtml';
protected $_template = 'test.phtml';
protected $_coreRegistry = null;
// public function __construct(
// MagentoBackendBlockWidgetContext $context,
// array $data = []
// )
// parent::__construct($context, $data);
//
// protected function _prepareLayout()
//
// parent::_prepareLayout();
// if (!$this->getTemplate())
// $this->setTemplate(static::IBAN_TEMPLATE);
//
//
// return $this;
//
my layout file
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabMeat" name="customerids_customerids_edit_tab_meat"/>
<arguments>
<argument name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">customerids_customerids_edit_tab_meat</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="string">2</item>
<item name="canShow" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">fieldset</item>
</argument>
</arguments>
magento2 module admin custom
add a comment |
I have created a custom module. When we click on the admin grid to edit, it opens edit page. In that I am showing tabs. When I click on that tab I need to show template file. If you see the below screen you can get idea
this is my tab file
<?php
/**
/**
* Exinent_Customerids Module
*
* @category customer
* @package
* @author pawan
*
*/
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
/**
* customerid post edit form main tab
*/
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
// const IBAN_TEMPLATE = 'Exinent_Customerids::test.phtml';
protected $_template = 'test.phtml';
protected $_coreRegistry = null;
// public function __construct(
// MagentoBackendBlockWidgetContext $context,
// array $data = []
// )
// parent::__construct($context, $data);
//
// protected function _prepareLayout()
//
// parent::_prepareLayout();
// if (!$this->getTemplate())
// $this->setTemplate(static::IBAN_TEMPLATE);
//
//
// return $this;
//
my layout file
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabMeat" name="customerids_customerids_edit_tab_meat"/>
<arguments>
<argument name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">customerids_customerids_edit_tab_meat</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="string">2</item>
<item name="canShow" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">fieldset</item>
</argument>
</arguments>
magento2 module admin custom
Please share the what you tried so far
– Amit Bera♦
Aug 10 '18 at 10:53
@AmitBera I have updated my question
– Pawankumar
Aug 10 '18 at 12:46
magento.stackexchange.com/questions/217621/… followed this link also process also
– Pawankumar
Aug 10 '18 at 13:03
add a comment |
I have created a custom module. When we click on the admin grid to edit, it opens edit page. In that I am showing tabs. When I click on that tab I need to show template file. If you see the below screen you can get idea
this is my tab file
<?php
/**
/**
* Exinent_Customerids Module
*
* @category customer
* @package
* @author pawan
*
*/
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
/**
* customerid post edit form main tab
*/
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
// const IBAN_TEMPLATE = 'Exinent_Customerids::test.phtml';
protected $_template = 'test.phtml';
protected $_coreRegistry = null;
// public function __construct(
// MagentoBackendBlockWidgetContext $context,
// array $data = []
// )
// parent::__construct($context, $data);
//
// protected function _prepareLayout()
//
// parent::_prepareLayout();
// if (!$this->getTemplate())
// $this->setTemplate(static::IBAN_TEMPLATE);
//
//
// return $this;
//
my layout file
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabMeat" name="customerids_customerids_edit_tab_meat"/>
<arguments>
<argument name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">customerids_customerids_edit_tab_meat</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="string">2</item>
<item name="canShow" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">fieldset</item>
</argument>
</arguments>
magento2 module admin custom
I have created a custom module. When we click on the admin grid to edit, it opens edit page. In that I am showing tabs. When I click on that tab I need to show template file. If you see the below screen you can get idea
this is my tab file
<?php
/**
/**
* Exinent_Customerids Module
*
* @category customer
* @package
* @author pawan
*
*/
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
/**
* customerid post edit form main tab
*/
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
// const IBAN_TEMPLATE = 'Exinent_Customerids::test.phtml';
protected $_template = 'test.phtml';
protected $_coreRegistry = null;
// public function __construct(
// MagentoBackendBlockWidgetContext $context,
// array $data = []
// )
// parent::__construct($context, $data);
//
// protected function _prepareLayout()
//
// parent::_prepareLayout();
// if (!$this->getTemplate())
// $this->setTemplate(static::IBAN_TEMPLATE);
//
//
// return $this;
//
my layout file
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabMeat" name="customerids_customerids_edit_tab_meat"/>
<arguments>
<argument name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">customerids_customerids_edit_tab_meat</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="opened" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="string">2</item>
<item name="canShow" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">fieldset</item>
</argument>
</arguments>
magento2 module admin custom
magento2 module admin custom
edited Aug 10 '18 at 12:44
twinkle_systematix
977 bronze badges
977 bronze badges
asked Aug 10 '18 at 10:17
PawankumarPawankumar
4185 silver badges20 bronze badges
4185 silver badges20 bronze badges
Please share the what you tried so far
– Amit Bera♦
Aug 10 '18 at 10:53
@AmitBera I have updated my question
– Pawankumar
Aug 10 '18 at 12:46
magento.stackexchange.com/questions/217621/… followed this link also process also
– Pawankumar
Aug 10 '18 at 13:03
add a comment |
Please share the what you tried so far
– Amit Bera♦
Aug 10 '18 at 10:53
@AmitBera I have updated my question
– Pawankumar
Aug 10 '18 at 12:46
magento.stackexchange.com/questions/217621/… followed this link also process also
– Pawankumar
Aug 10 '18 at 13:03
Please share the what you tried so far
– Amit Bera♦
Aug 10 '18 at 10:53
Please share the what you tried so far
– Amit Bera♦
Aug 10 '18 at 10:53
@AmitBera I have updated my question
– Pawankumar
Aug 10 '18 at 12:46
@AmitBera I have updated my question
– Pawankumar
Aug 10 '18 at 12:46
magento.stackexchange.com/questions/217621/… followed this link also process also
– Pawankumar
Aug 10 '18 at 13:03
magento.stackexchange.com/questions/217621/… followed this link also process also
– Pawankumar
Aug 10 '18 at 13:03
add a comment |
2 Answers
2
active
oldest
votes
You need to confirm that, you create
test.phtmlfile at this location.VendorModulenameviewadminhtmltemplatestest.phtmlYou need to replace _prepareLayout function code like this.
<?php
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
protected function _prepareLayout()
$customhtml = parent::_prepareLayout();
$customhtml .= $this->setTemplate('Vendor_Modulename::test.phtml')->toHtml();
return $customhtml;
How can we access variables defined in prepareLayout function to template file?
– Khushbu
Jul 12 at 12:35
@Khushbu please ask the seprate question so you get your answer.
– Dhiren Vasoya
Jul 12 at 12:42
Asked on magento.stackexchange.com/questions/281901/…
– Khushbu
Jul 12 at 12:57
add a comment |
1.In the layout file you can add the code :
<referenceContainer name="left">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTab" name="customerids_customerids_edit_tab">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabChild" name="customerids_customerids_edit_tab_child"/>
<action method="addTab">
<argument name="name" xsi:type="string">child_section</argument>
<argument name="block" xsi:type="string">customerids_customerids_edit_tab_child</argument>
</action>
</block>
</referenceContainer>
2.Create the new file on the path :
VendorModulenameBlockAdminhtmlCustomeridsEditTabChild.php
With content :
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
class Child extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
/**
* @var MagentoBackendBlockWidgetFormRendererFieldset
*/
protected $_rendererFieldset;
/**
* @var MagentoStoreModelSystemStore
*/
protected $_systemStore;
protected $_customerFactory;
protected $_resource;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoStoreModelSystemStore $systemStore
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoStoreModelSystemStore $systemStore,
MagentoBackendBlockWidgetFormRendererFieldset $rendererFieldset,
MagentoCustomerModelCustomerFactory $customerFactory,
MagentoFrameworkAppResourceConnection $resource,
array $data = []
)
$this->_systemStore = $systemStore;
$this->_rendererFieldset = $rendererFieldset;
$this->_customerFactory = $customerFactory;
$this->_resource = $resource;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
/* @var $model MagefanBlogModelCategory */
$model = $this->_coreRegistry->registry('current_model');
/*
* Checking if user have permissions to save information
*/
$isElementDisabled = !$this->_isAllowedAction('Vendor_Modulename::child');
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('child_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Add Your Child')]);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id']);
$fieldset->addField(
'html',
'text',
[
'name' => 'html',
'label' => __('Html Content'),
'title' => __('Html Content'),
'required' => true,
'disabled' => $isElementDisabled
]
)->setRenderer($this->_rendererFieldset->setTemplate('Vendor_Modulename::child.phtml'));
if (!$model->getId())
$model->setData('status', $isElementDisabled ? '0' : '1');
$this->_eventManager->dispatch('vendor_modulename_edit_tab_main_prepare_form', ['form' => $form]);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
/**
* Prepare label for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabLabel()
return __('Html Content');
/**
* Prepare title for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabTitle()
return __('Html Content');
/**
* Returns status flag about this tab can be shown or not
*
* @return bool
*/
public function canShowTab()
return true;
/**
* Returns status flag about this tab hidden or not
*
* @return bool
*/
public function isHidden()
return false;
/**
* Check permission for passed action
*
* @param string $resourceId
* @return bool
*/
protected function _isAllowedAction($resourceId)
return $this->_authorization->isAllowed($resourceId);
3.Create file :
Vendor/Modulename/view/adminhtml/templates/child.phtml
And put your content here
Hope it helps !
How can we access variables defined in prepareForm function to template file?
– Khushbu
Jul 12 at 10:51
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f237944%2fhow-to-add-phtml-file-at-edit-tab-of-magento-2-custom-module-in-admin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to confirm that, you create
test.phtmlfile at this location.VendorModulenameviewadminhtmltemplatestest.phtmlYou need to replace _prepareLayout function code like this.
<?php
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
protected function _prepareLayout()
$customhtml = parent::_prepareLayout();
$customhtml .= $this->setTemplate('Vendor_Modulename::test.phtml')->toHtml();
return $customhtml;
How can we access variables defined in prepareLayout function to template file?
– Khushbu
Jul 12 at 12:35
@Khushbu please ask the seprate question so you get your answer.
– Dhiren Vasoya
Jul 12 at 12:42
Asked on magento.stackexchange.com/questions/281901/…
– Khushbu
Jul 12 at 12:57
add a comment |
You need to confirm that, you create
test.phtmlfile at this location.VendorModulenameviewadminhtmltemplatestest.phtmlYou need to replace _prepareLayout function code like this.
<?php
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
protected function _prepareLayout()
$customhtml = parent::_prepareLayout();
$customhtml .= $this->setTemplate('Vendor_Modulename::test.phtml')->toHtml();
return $customhtml;
How can we access variables defined in prepareLayout function to template file?
– Khushbu
Jul 12 at 12:35
@Khushbu please ask the seprate question so you get your answer.
– Dhiren Vasoya
Jul 12 at 12:42
Asked on magento.stackexchange.com/questions/281901/…
– Khushbu
Jul 12 at 12:57
add a comment |
You need to confirm that, you create
test.phtmlfile at this location.VendorModulenameviewadminhtmltemplatestest.phtmlYou need to replace _prepareLayout function code like this.
<?php
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
protected function _prepareLayout()
$customhtml = parent::_prepareLayout();
$customhtml .= $this->setTemplate('Vendor_Modulename::test.phtml')->toHtml();
return $customhtml;
You need to confirm that, you create
test.phtmlfile at this location.VendorModulenameviewadminhtmltemplatestest.phtmlYou need to replace _prepareLayout function code like this.
<?php
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
use MagentoBackendBlockTemplateContext;
use MagentoFrameworkRegistry;
class Meat extends MagentoBackendBlockTemplate
protected function _prepareLayout()
$customhtml = parent::_prepareLayout();
$customhtml .= $this->setTemplate('Vendor_Modulename::test.phtml')->toHtml();
return $customhtml;
answered Aug 17 '18 at 14:08
Dhiren VasoyaDhiren Vasoya
4,9455 gold badges21 silver badges47 bronze badges
4,9455 gold badges21 silver badges47 bronze badges
How can we access variables defined in prepareLayout function to template file?
– Khushbu
Jul 12 at 12:35
@Khushbu please ask the seprate question so you get your answer.
– Dhiren Vasoya
Jul 12 at 12:42
Asked on magento.stackexchange.com/questions/281901/…
– Khushbu
Jul 12 at 12:57
add a comment |
How can we access variables defined in prepareLayout function to template file?
– Khushbu
Jul 12 at 12:35
@Khushbu please ask the seprate question so you get your answer.
– Dhiren Vasoya
Jul 12 at 12:42
Asked on magento.stackexchange.com/questions/281901/…
– Khushbu
Jul 12 at 12:57
How can we access variables defined in prepareLayout function to template file?
– Khushbu
Jul 12 at 12:35
How can we access variables defined in prepareLayout function to template file?
– Khushbu
Jul 12 at 12:35
@Khushbu please ask the seprate question so you get your answer.
– Dhiren Vasoya
Jul 12 at 12:42
@Khushbu please ask the seprate question so you get your answer.
– Dhiren Vasoya
Jul 12 at 12:42
Asked on magento.stackexchange.com/questions/281901/…
– Khushbu
Jul 12 at 12:57
Asked on magento.stackexchange.com/questions/281901/…
– Khushbu
Jul 12 at 12:57
add a comment |
1.In the layout file you can add the code :
<referenceContainer name="left">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTab" name="customerids_customerids_edit_tab">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabChild" name="customerids_customerids_edit_tab_child"/>
<action method="addTab">
<argument name="name" xsi:type="string">child_section</argument>
<argument name="block" xsi:type="string">customerids_customerids_edit_tab_child</argument>
</action>
</block>
</referenceContainer>
2.Create the new file on the path :
VendorModulenameBlockAdminhtmlCustomeridsEditTabChild.php
With content :
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
class Child extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
/**
* @var MagentoBackendBlockWidgetFormRendererFieldset
*/
protected $_rendererFieldset;
/**
* @var MagentoStoreModelSystemStore
*/
protected $_systemStore;
protected $_customerFactory;
protected $_resource;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoStoreModelSystemStore $systemStore
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoStoreModelSystemStore $systemStore,
MagentoBackendBlockWidgetFormRendererFieldset $rendererFieldset,
MagentoCustomerModelCustomerFactory $customerFactory,
MagentoFrameworkAppResourceConnection $resource,
array $data = []
)
$this->_systemStore = $systemStore;
$this->_rendererFieldset = $rendererFieldset;
$this->_customerFactory = $customerFactory;
$this->_resource = $resource;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
/* @var $model MagefanBlogModelCategory */
$model = $this->_coreRegistry->registry('current_model');
/*
* Checking if user have permissions to save information
*/
$isElementDisabled = !$this->_isAllowedAction('Vendor_Modulename::child');
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('child_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Add Your Child')]);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id']);
$fieldset->addField(
'html',
'text',
[
'name' => 'html',
'label' => __('Html Content'),
'title' => __('Html Content'),
'required' => true,
'disabled' => $isElementDisabled
]
)->setRenderer($this->_rendererFieldset->setTemplate('Vendor_Modulename::child.phtml'));
if (!$model->getId())
$model->setData('status', $isElementDisabled ? '0' : '1');
$this->_eventManager->dispatch('vendor_modulename_edit_tab_main_prepare_form', ['form' => $form]);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
/**
* Prepare label for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabLabel()
return __('Html Content');
/**
* Prepare title for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabTitle()
return __('Html Content');
/**
* Returns status flag about this tab can be shown or not
*
* @return bool
*/
public function canShowTab()
return true;
/**
* Returns status flag about this tab hidden or not
*
* @return bool
*/
public function isHidden()
return false;
/**
* Check permission for passed action
*
* @param string $resourceId
* @return bool
*/
protected function _isAllowedAction($resourceId)
return $this->_authorization->isAllowed($resourceId);
3.Create file :
Vendor/Modulename/view/adminhtml/templates/child.phtml
And put your content here
Hope it helps !
How can we access variables defined in prepareForm function to template file?
– Khushbu
Jul 12 at 10:51
add a comment |
1.In the layout file you can add the code :
<referenceContainer name="left">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTab" name="customerids_customerids_edit_tab">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabChild" name="customerids_customerids_edit_tab_child"/>
<action method="addTab">
<argument name="name" xsi:type="string">child_section</argument>
<argument name="block" xsi:type="string">customerids_customerids_edit_tab_child</argument>
</action>
</block>
</referenceContainer>
2.Create the new file on the path :
VendorModulenameBlockAdminhtmlCustomeridsEditTabChild.php
With content :
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
class Child extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
/**
* @var MagentoBackendBlockWidgetFormRendererFieldset
*/
protected $_rendererFieldset;
/**
* @var MagentoStoreModelSystemStore
*/
protected $_systemStore;
protected $_customerFactory;
protected $_resource;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoStoreModelSystemStore $systemStore
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoStoreModelSystemStore $systemStore,
MagentoBackendBlockWidgetFormRendererFieldset $rendererFieldset,
MagentoCustomerModelCustomerFactory $customerFactory,
MagentoFrameworkAppResourceConnection $resource,
array $data = []
)
$this->_systemStore = $systemStore;
$this->_rendererFieldset = $rendererFieldset;
$this->_customerFactory = $customerFactory;
$this->_resource = $resource;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
/* @var $model MagefanBlogModelCategory */
$model = $this->_coreRegistry->registry('current_model');
/*
* Checking if user have permissions to save information
*/
$isElementDisabled = !$this->_isAllowedAction('Vendor_Modulename::child');
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('child_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Add Your Child')]);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id']);
$fieldset->addField(
'html',
'text',
[
'name' => 'html',
'label' => __('Html Content'),
'title' => __('Html Content'),
'required' => true,
'disabled' => $isElementDisabled
]
)->setRenderer($this->_rendererFieldset->setTemplate('Vendor_Modulename::child.phtml'));
if (!$model->getId())
$model->setData('status', $isElementDisabled ? '0' : '1');
$this->_eventManager->dispatch('vendor_modulename_edit_tab_main_prepare_form', ['form' => $form]);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
/**
* Prepare label for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabLabel()
return __('Html Content');
/**
* Prepare title for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabTitle()
return __('Html Content');
/**
* Returns status flag about this tab can be shown or not
*
* @return bool
*/
public function canShowTab()
return true;
/**
* Returns status flag about this tab hidden or not
*
* @return bool
*/
public function isHidden()
return false;
/**
* Check permission for passed action
*
* @param string $resourceId
* @return bool
*/
protected function _isAllowedAction($resourceId)
return $this->_authorization->isAllowed($resourceId);
3.Create file :
Vendor/Modulename/view/adminhtml/templates/child.phtml
And put your content here
Hope it helps !
How can we access variables defined in prepareForm function to template file?
– Khushbu
Jul 12 at 10:51
add a comment |
1.In the layout file you can add the code :
<referenceContainer name="left">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTab" name="customerids_customerids_edit_tab">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabChild" name="customerids_customerids_edit_tab_child"/>
<action method="addTab">
<argument name="name" xsi:type="string">child_section</argument>
<argument name="block" xsi:type="string">customerids_customerids_edit_tab_child</argument>
</action>
</block>
</referenceContainer>
2.Create the new file on the path :
VendorModulenameBlockAdminhtmlCustomeridsEditTabChild.php
With content :
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
class Child extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
/**
* @var MagentoBackendBlockWidgetFormRendererFieldset
*/
protected $_rendererFieldset;
/**
* @var MagentoStoreModelSystemStore
*/
protected $_systemStore;
protected $_customerFactory;
protected $_resource;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoStoreModelSystemStore $systemStore
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoStoreModelSystemStore $systemStore,
MagentoBackendBlockWidgetFormRendererFieldset $rendererFieldset,
MagentoCustomerModelCustomerFactory $customerFactory,
MagentoFrameworkAppResourceConnection $resource,
array $data = []
)
$this->_systemStore = $systemStore;
$this->_rendererFieldset = $rendererFieldset;
$this->_customerFactory = $customerFactory;
$this->_resource = $resource;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
/* @var $model MagefanBlogModelCategory */
$model = $this->_coreRegistry->registry('current_model');
/*
* Checking if user have permissions to save information
*/
$isElementDisabled = !$this->_isAllowedAction('Vendor_Modulename::child');
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('child_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Add Your Child')]);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id']);
$fieldset->addField(
'html',
'text',
[
'name' => 'html',
'label' => __('Html Content'),
'title' => __('Html Content'),
'required' => true,
'disabled' => $isElementDisabled
]
)->setRenderer($this->_rendererFieldset->setTemplate('Vendor_Modulename::child.phtml'));
if (!$model->getId())
$model->setData('status', $isElementDisabled ? '0' : '1');
$this->_eventManager->dispatch('vendor_modulename_edit_tab_main_prepare_form', ['form' => $form]);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
/**
* Prepare label for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabLabel()
return __('Html Content');
/**
* Prepare title for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabTitle()
return __('Html Content');
/**
* Returns status flag about this tab can be shown or not
*
* @return bool
*/
public function canShowTab()
return true;
/**
* Returns status flag about this tab hidden or not
*
* @return bool
*/
public function isHidden()
return false;
/**
* Check permission for passed action
*
* @param string $resourceId
* @return bool
*/
protected function _isAllowedAction($resourceId)
return $this->_authorization->isAllowed($resourceId);
3.Create file :
Vendor/Modulename/view/adminhtml/templates/child.phtml
And put your content here
Hope it helps !
1.In the layout file you can add the code :
<referenceContainer name="left">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTab" name="customerids_customerids_edit_tab">
<block class="VendorModulenameBlockAdminhtmlCustomeridsEditTabChild" name="customerids_customerids_edit_tab_child"/>
<action method="addTab">
<argument name="name" xsi:type="string">child_section</argument>
<argument name="block" xsi:type="string">customerids_customerids_edit_tab_child</argument>
</action>
</block>
</referenceContainer>
2.Create the new file on the path :
VendorModulenameBlockAdminhtmlCustomeridsEditTabChild.php
With content :
namespace VendorModulenameBlockAdminhtmlCustomeridsEditTab;
class Child extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
/**
* @var MagentoBackendBlockWidgetFormRendererFieldset
*/
protected $_rendererFieldset;
/**
* @var MagentoStoreModelSystemStore
*/
protected $_systemStore;
protected $_customerFactory;
protected $_resource;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoStoreModelSystemStore $systemStore
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoStoreModelSystemStore $systemStore,
MagentoBackendBlockWidgetFormRendererFieldset $rendererFieldset,
MagentoCustomerModelCustomerFactory $customerFactory,
MagentoFrameworkAppResourceConnection $resource,
array $data = []
)
$this->_systemStore = $systemStore;
$this->_rendererFieldset = $rendererFieldset;
$this->_customerFactory = $customerFactory;
$this->_resource = $resource;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
/* @var $model MagefanBlogModelCategory */
$model = $this->_coreRegistry->registry('current_model');
/*
* Checking if user have permissions to save information
*/
$isElementDisabled = !$this->_isAllowedAction('Vendor_Modulename::child');
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('child_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Add Your Child')]);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id']);
$fieldset->addField(
'html',
'text',
[
'name' => 'html',
'label' => __('Html Content'),
'title' => __('Html Content'),
'required' => true,
'disabled' => $isElementDisabled
]
)->setRenderer($this->_rendererFieldset->setTemplate('Vendor_Modulename::child.phtml'));
if (!$model->getId())
$model->setData('status', $isElementDisabled ? '0' : '1');
$this->_eventManager->dispatch('vendor_modulename_edit_tab_main_prepare_form', ['form' => $form]);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
/**
* Prepare label for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabLabel()
return __('Html Content');
/**
* Prepare title for tab
*
* @return MagentoFrameworkPhrase
*/
public function getTabTitle()
return __('Html Content');
/**
* Returns status flag about this tab can be shown or not
*
* @return bool
*/
public function canShowTab()
return true;
/**
* Returns status flag about this tab hidden or not
*
* @return bool
*/
public function isHidden()
return false;
/**
* Check permission for passed action
*
* @param string $resourceId
* @return bool
*/
protected function _isAllowedAction($resourceId)
return $this->_authorization->isAllowed($resourceId);
3.Create file :
Vendor/Modulename/view/adminhtml/templates/child.phtml
And put your content here
Hope it helps !
edited Aug 20 '18 at 3:37
answered Aug 20 '18 at 3:07
Vu Tran KienVu Tran Kien
3821 gold badge3 silver badges24 bronze badges
3821 gold badge3 silver badges24 bronze badges
How can we access variables defined in prepareForm function to template file?
– Khushbu
Jul 12 at 10:51
add a comment |
How can we access variables defined in prepareForm function to template file?
– Khushbu
Jul 12 at 10:51
How can we access variables defined in prepareForm function to template file?
– Khushbu
Jul 12 at 10:51
How can we access variables defined in prepareForm function to template file?
– Khushbu
Jul 12 at 10:51
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f237944%2fhow-to-add-phtml-file-at-edit-tab-of-magento-2-custom-module-in-admin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please share the what you tried so far
– Amit Bera♦
Aug 10 '18 at 10:53
@AmitBera I have updated my question
– Pawankumar
Aug 10 '18 at 12:46
magento.stackexchange.com/questions/217621/… followed this link also process also
– Pawankumar
Aug 10 '18 at 13:03