Good evening. I just recently started learning magento 2 and faced the following problem. I have an XML form that contains information, such as "Name, address, telephone" I need to create a block that will return which fields will be in the fieldset, but I dont know how I think that I'm calling the wrong class, I ask for help. Ty my code:


<fieldset class="[Vendor]\[Module]\Block\Adminhtml\[Module]\Edit\Tab\Checkbox" />


<preference for="Magento\Tax\Block\Adminhtml\Rate\Form" type="[Vendor]\[Module]\Block\Adminhtml\[Module]\Edit\Tab\Checkbox" />


class Checkbox extends \Magento\Tax\Block\Adminhtml\Rate\Form

    protected $_taxData = null;

     * @var \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory
    protected $_fieldsetFactory;

     * @var \Magento\Directory\Model\Config\Source\Country
    protected $_country;

     * @var \Magento\Directory\Model\RegionFactory
    protected $_regionFactory;

     * @var \Magento\Tax\Api\TaxRateRepositoryInterface
    protected $_taxRateRepository;

     * @var \Magento\Tax\Model\TaxRateCollection
    protected $_taxRateCollection;

     * @var \Magento\Tax\Model\Calculation\Rate\Converter
    protected $_taxRateConverter;

     * @param \Magento\Backend\Block\Template\Context $context
     * @param \Magento\Framework\Registry $registry
     * @param \Magento\Framework\Data\FormFactory $formFactory
     * @param \Magento\Directory\Model\RegionFactory $regionFactory
     * @param \Magento\Directory\Model\Config\Source\Country $country
     * @param \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory $fieldsetFactory
     * @param \Magento\Tax\Helper\Data $taxData
     * @param \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository
     * @param \Magento\Tax\Model\TaxRateCollection $taxRateCollection
     * @param \Magento\Tax\Model\Calculation\Rate\Converter $taxRateConverter
     * @param array $data
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Framework\Registry $registry,
        \Magento\Framework\Data\FormFactory $formFactory,
        \Magento\Directory\Model\RegionFactory $regionFactory,
        \Magento\Directory\Model\Config\Source\Country $country,
        \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory $fieldsetFactory,
        \Magento\Tax\Helper\Data $taxData,
        \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository,
        \Magento\Tax\Model\TaxRateCollection $taxRateCollection,
        \Magento\Tax\Model\Calculation\Rate\Converter $taxRateConverter,
        array $data = []
    ) {
        parent::__construct($context, $registry, $formFactory, $regionFactory, $country, $fieldsetFactory, $taxData, $taxRateRepository, $taxRateCollection, $taxRateConverter, $data);


     * @return void
    protected function _construct()

    public function _prepareForm()

            $form = $this->getForm();
            $fieldset = $form->п('new_fieldset',
                array('legend'=>'GST Tax Rate Information')
            $fieldset->addField('hsn_title', 'text',
                    'label' => 'HSN Code',
                    'class' => 'input-text',
                    'name'  => 'hsn_title',
                    'required' => false

            return $this;

1 Answer 1


custom filed in admin grid can be added in XML file. This XML file is created under view/adminhtml/layout and also view/adminhtml/layout/ui_component folders.

In view/adminhtml/layout create layout file which should be something like this

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <update handle="styles"/>
        <referenceContainer name="content">
            <uiComponent name="frontname_controlername_listing"/>

In view/adminhtml/layout/ui_component folder

create a file which should be mentioned in above layout file in this example it is frontname_controlername_listing

this XML file includes many things and you just wanted custom field to add so adding code specific to that.

<column name="name of filed">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="sorting" xsi:type="string">asc</item>
                    <item name="label" xsi:type="string" translate="true">Name of filed </item>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.