Hello Magento Friends,

In this Magento tutorial, we will find out How to Add Dynamic Field in Admin Product Edit Form.

Magento provides flexibility to customize product attributes and forms according to specific business needs. By adding dynamic fields in admin product edit form you can tailor your product information to match your unique requirements without modifying the core code.

So let’s get started.

Steps to Add Dynamic Field in Product Create/Edit Form in Magento 2:

Here city and related shipping cost is saved on product. We can use this data on phtml file, controller file . 

Step 1: Create product attribute using below code. Using attributes we can save data of dynamic fields.

Add code at the below path


Step 2: Add code in the Model file


Step 3: Create di.xml file at the following path.


And add the below-mentioned code.

Step 4: Create ui component file at the following path 


Now, add the below code snippet

Step 5: Create an event file at the path as follows to save attribute data. 


And include the following piece of code

Step 6: Create observer file at the following path to save attribute data


Then add the below code


You can add multiple fields by clicking “Add Shipping Price”. 

custom field product edit form


So this way, you can add dynamic fields in the product edit form in Magento 2. Utilize this capability to enhance your e-commerce store’s product management experience and gain a competitive edge in the market.

Happy Coding!

Click to rate this post!
[Total: 3 Average: 3.7]