In Magento2 custom module, I need to add an two input fields say text1 & text2 which will be dynamic and will have "Add More option". so clicking on Add More will add two new fields in the form, How I can do it? Please help

1 Answer 1


I have followed the below steps and get it working.


Goto your Form.php under app/code/[vendor]/[module]/Block/Adminhtml/.../Edit/ and call your custom template file by using below code

protected $_template = '[vendor]_[module]::[directory name under templates]/form.phtml';

and create form.phtml on desired location. Now you can add your own code to your form.phtml file and add the form action according to your module controller action.

Now you need to edit the _prepareForm function and comment out the following line


Now you need to edit the saveAction of your controller to save the data according to your requirement.

Hope this helps.

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.