I am trying to add a custom field to Admin Store Edit
I have overridden the block function _prepareStoreFieldset
locate in vendor/magento/module-backend/Block/System/Store/Edit/Form/Website.php
This is my etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Backend\Block\System\Store\Edit\Form\Website">
<preference for="Magento\Backend\Block\System\Store\Edit\Form\Website" type="Vendor\Module\Block\System\Store\Edit\Form\Website" />
</type>
</config>
Then I created a file in Vendor\Module\Block\System\Store\Edit\Form
<?php
namespace Vendor\Module\Block\System\Store\Edit\Form;
/**
* Adminhtml store edit form for the website
*
* @author Magento Core Team <[email protected]>
*
* @SuppressWarnings(PHPMD.DepthOfInheritance)
*/
class Website extends \Magento\Backend\Block\System\Store\Edit\Form\Website
{
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Data\FormFactory $formFactory
* @param \Magento\Store\Model\GroupFactory $groupFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Store\Model\GroupFactory $groupFactory,
array $data = []
) {
parent::__construct($context, $registry, $formFactory, $groupFactory, $data);
}
/**
* Prepare website specific fieldset
*
* @param \Magento\Framework\Data\Form $form
* @return void
*/
public function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
{
$fieldset = $form->getForm()->getElement('website_fieldset');
$fieldset->addField(
'website_type',
'text',
[
'name' => 'website[type]',
'label' => __('Type'),
'value' => 1,
'required' => true,
'disabled' => false
]
);
}
}
But it did not work. Anywhere I am wrong? Please help me. Thanks