---
title: "Magento 2: Add Custom Field and Save Value in Product Attribute Add Form"
url: "https://magecomp.com/blog/magento-2-add-custom-field-and-save-value-in-product-attribute-add-form/"
date: "2022-08-26T12:35:11+00:00"
modified: "2025-02-14T07:06:15+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 417
reading_time: "3 min read"
summary: "Hello Magento Friends,"
description: "Add Custom Field and Save Value in Product Attribute Add Form in Magento 2. Learn more"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Magento 2: How to Pass Multi-Dimensional Array as an Argument in REST API"
    url: "https://magecomp.com/blog/magento-2-pass-multi-dimensional-array-as-argument-in-rest-api/"
  - title: "How to Add Website Total Visitor on Admin Dashboard in Magento 2?"
    url: "https://magecomp.com/blog/add-website-total-visitor-on-admin-dashboard-magento-2/"
  - title: "Magento 2: Add extra “Proceed to Checkout” Button on top of grid on shopping cart page"
    url: "https://magecomp.com/blog/magento-2-add-extra-proceed-to-checkout-button-on-top-of-grid-on-shopping-cart-page/"
---

# Magento 2: Add Custom Field and Save Value in Product Attribute Add Form

_Published: August 26, 2022_  
_Author: Dhiren Vasoya_  

![Add Custom Field and Save Value in Product Attribute Add Form in M2](https://magecomp.com/blog/wp-content/uploads/2022/08/Add-Custom-Field-and-Save-Value-in-Product-Attribute-Add-Form-in-M2-1024x512.webp)

**Hello Magento Friends,**

Today we will get the solution for Magento 2: Add Custom Field and Save Value in Product Attribute Add Form.
[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-2.webp)](https://magecomp.com/magento-performance-optimization.html)

Customization is the biggest advantage of the Magento eCommerce platform. You can customize every aspect of your Magento 2 website. Product attributes determine the characteristics of a product. You can add a custom field in the product attribute form in Magento 2.
## Steps to Add Custom Field and Save Value in Product Attribute Add Form in Magento 2:
**Step 1:** First we need to create a **“di.xml”** file inside the etc folder
**app\code\Vendor\Extension\etc\adminhtml**

Now, add the code as follows
```
<?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="MagentoCatalogBlockAdminhtmlProductAttributeEditTabFront">
        <plugin name="extension_attribute_edit_form" type="VendorExtensionPluginBlockAdminhtmlProductAttributeEditTabFront" sortOrder="1"/>
    </type>
</config>
```

**Step 2:** In the next step, we will create the **“Front.php”** file inside the Plugin folder
**app\code\Vendor\Extension\Plugin\Block\Adminhtml\Product\Attribute\Edit\Tab**

Then append the below-mentioned code snippet
```
<?php
namespace VendorExtensionPluginBlockAdminhtmlProductAttributeEditTab;

class Front
{

    protected $custom;

    public function __construct(
        MagentoConfigModelConfigSourceYesno $custom
    ) {
        $this->custom = $custom;
    }

    public function aroundGetFormHtml(
        MagentoCatalogBlockAdminhtmlProductAttributeEditTabFront $subject,
        Closure $proceed
    )
    {

        $customSource = $this->custom->toOptionArray();
        $form = $subject->getForm();
        $fieldset = $form->getElement('front_fieldset');
        $fieldset->addField(
            'used_in_custom',
            'select',
            [
                'name' => 'used_in_custom',
                'label' => __('Used in Custom'),
                'title' => __('Used in Custom'),
                'values' => $customSource,
            ]
        );
        return $proceed();
    }
}
```

[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-6.webp)](https://magecomp.com/services/hyva-theme-development/)

**Step 3:** Then we will create the **“db_schema.xml”** file inside the etc folder
**app\code\Vendor\Extension\etc**

Finally, add the following code
```
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="catalog_eav_attribute" resource="default" engine="innodb" comment="Catalog EAV Attribute Table">
        <column xsi:type="smallint" name="used_in_custom" unsigned="true" nullable="false"
                identity="false" default="0" comment="Custom forms"/>
   </table>
</schema>
```

**Output:**

[![custom product field](https://magecomp.com/blog/wp-content/uploads/2022/08/custom-product-field.png)](https://magecomp.com/blog/wp-content/uploads/2022/08/custom-product-field.png)

## Conclusion:
This way you can Add Custom Field and Save Value in Product Attribute Add Form in Magento 2. If you have any doubt let me know through the comment box. Share the article and stay in touch for further Magento 2 solutions.
[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-4.webp)](https://magecomp.com/services/hire-magento-programmer/)

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/magento-2-add-custom-field-and-save-value-in-product-attribute-add-form/](https://magecomp.com/blog/magento-2-add-custom-field-and-save-value-in-product-attribute-add-form/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-12 18:55:12 UTC_  
