How to add the "Please Wait" popup when submitting a form in magento

How to add the "Please Wait" popup when submitting a form in magento

July 23, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to add the "Please Wait" popup when submitting a form in magento

Showing the “Please Wait” Popup on Form Submission in Magento

As a senior developer working extensively with Magento, I often encounter scenarios where clients require additional functionality like displaying the “Please Wait” popup during form submissions. This is particularly useful when you want to provide feedback to the user while the system processes their input.

In your case, you’re dealing with an admin module that doesn’t use any PHTML files and submits forms dynamically. Let’s go through the steps required to implement this feature.

Understanding the “Please Wait” Popup

The “Please Wait” popup in Magento is a built-in feature triggered by the submitForm JavaScript function. When you call this function, it displays a modal box with a loading icon while processing an AJAX request.

By default, when you perform certain actions like editing categories or updating product attributes through the admin panel, Magento automatically triggers this “Please Wait” popup thanks to the underlying JavaScript integration.

Implementing the “Please Wait” Popup in Your Module

Since your form is generated programmatically and not tied to any PHTML file, we’ll need to override some of the default Magento behavior. Here’s a step-by-step guide:

  1. Override the Save Button

First, you need to override the default save button for your form. You can do this in your module controller or in the saveAction method if you have one.

$this->getButton('save')->setData(
    'onclick', "submitForm();"
);

This line of code replaces the default save action with a JavaScript function called submitForm().

  1. Include Your JavaScript File

Next, you need to include your custom JavaScript file that contains the submitForm function.

In your module layout XML file (usually named layout.xml), add a reference to your JS script:

<reference name="head">
    <action method="addJs">
        <script>mymodule/javascript.js</script>
    </action>
</reference>

Replace mymodule with the actual namespace of your module.

  1. Create Your JavaScript Function

Now, create a new JS file (e.g., JavaScript.js) in your module’s view directory and define the submitForm function:

function submitForm(){
    Form.submit('edit_form', 'adminhtml/your_module/save');
}

Replace 'your_module' with the actual name of your module.

  1. Connect Your Form to JavaScript

Finally, ensure your form has an ID that matches what you’re passing to the submit function in the previous step.

In your controller or save action, set the form’s ID:

$this->getForm()->setData('id', 'edit_form');

Note: If you are using a third-party form object or a custom form class, ensure it has an ID property that can be set to ‘edit_form’.

Conclusion

By following these steps, you should now have the “Please Wait” popup appearing when submitting your dynamic admin forms in Magento.

Remember, this is a basic implementation. Depending on your specific use case, you might need to customize the JavaScript logic or handle errors differently.

For more advanced techniques and best practices for working with Magento’s core functionality, I recommend checking out the official documentation here.

If you found this solution helpful, feel free to share it on your favorite developer communities. Your feedback is always appreciated!

Happy coding!

Catalog Extensions Themes Admin

Our network