Hello Magento Friends,

How are you all doing? Today I am going to figure out How to Create a Form Popup Modal in Magento 2. Before starting, have a look at our previously published blog, How to get Magento 2 all stores programmatically (Retrieve a list of all stores).

Let’s start with our today’s discussion,

Introduction:

The modal popup is a child window that requires user interaction before the user can return to the parent window. They help to get work done without showing all information on the main screen.

In Magento 2, you can create modal popups for forms. To create a form popup modal in Magento 2, follow the below steps.

Steps to Create a Form Popup Modal in Magento 2:

Step 1: Firstly, we need to create a “registration.php” file inside our extension folder on this path.

app\code\Vendor\Extension

Now, add the below code as mentioned below

Step 2: After that, we need to create a “module.xml” file inside the etc directory of our extension

app\code\Vendor\Extension\etc

And add the below code

Step 3: After that, we need to create a “routes.xml” file inside etc frontend directory of our extension

app\code\Vendor\Extension\frontend\etc

And add the below-mentioned code

Step 4: First, we need to create an “extension_index_index.xml” file inside the extension at the following path

app\code\Vendor\Extension\view\frontend\layout

Now, add the code as follows

Step 5: After that, we need to create a “custom.phtml” file inside the extension on the following path.

app\code\Vendor\Extension\view\frontend\templates

Finally, add the below code

Successfully performing the above steps, will show the Custom Form Popup window.

form popup modal

Conclusion:

This way you can Create a Form Popup Modal in Magento 2. If you come across any issues while implementing the above steps, feel free to reach me via the comment section. I will be happy to solve it. Share the article with your friends, colleagues, and social media platforms. Will catch you in the next tutorial, till then stay in the know.

Happy Coding!

Click to rate this post!
[Total: 18 Average: 4.6]