Title: A small initialization bug
Last modified: November 22, 2022

---

# A small initialization bug

 *  Resolved [electromystyle](https://wordpress.org/support/users/electromystyle/)
 * (@electromystyle)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/a-small-initialization-bug/)
 * Hello, I have identified a small problem in your plugin. For example, I create
   a form for a popup window and add it to my post via a button. On the same page
   of the sidebar post, I have a similar form. It doesn’t matter if the form IDs
   match or they are different. At first, the form in the sidebar works fine, it
   outputs validation errors in a single instance. But after I click the display
   button in the post, <span class=”wpcf7-spinner”/> elements and other validation
   elements are added to the form in the sidebar. With each new click on the button,
   new elements are added to the form in the sidebar, which leads to duplication
   of validation elements. I have analyzed your code and this problem is in the 
   file **frontend.js**
 *     ```
       // For CF7 5.4 and after
       if ( typeof wpcf7.init === 'function' ) {
           document.querySelectorAll(".wpcf7 > form").forEach(function (e) {
               return wpcf7.init(e);
           });
       }
       ```
   
 * It turns out that each form on the page is initialized again and again, and should
   be initialized only in the popup window.
    To fix this problem , it is enough 
   to specify a class `.wpb-pcf-form-style-true .wpcf7 > form` or something like
   that
 * You can reproduce this problem on the page I attached
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fa-small-initialization-bug%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [WPBean](https://wordpress.org/support/users/wpbean/)
 * (@wpbean)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/a-small-initialization-bug/#post-16228137)
 * Hi [@electromystyle](https://wordpress.org/support/users/electromystyle/)
 * Thanks for pointing out this issue. I just fixed it and released an update.
 *  Thread Starter [electromystyle](https://wordpress.org/support/users/electromystyle/)
 * (@electromystyle)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/a-small-initialization-bug/#post-16228148)
 * Okay, thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘A small initialization bug’ is closed to new replies.

 * ![](https://ps.w.org/wpb-popup-for-contact-form-7/assets/icon-256x256.png?rev
   =2497336)
 * [WPB Popup for Contact Form 7 – Showing Contact Form 7 Popup on Button Click](https://wordpress.org/plugins/wpb-popup-for-contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpb-popup-for-contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpb-popup-for-contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/wpb-popup-for-contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpb-popup-for-contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpb-popup-for-contact-form-7/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [electromystyle](https://wordpress.org/support/users/electromystyle/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/a-small-initialization-bug/#post-16228148)
 * Status: resolved