Title: Problem with select2.js script
Last modified: July 13, 2021

---

# Problem with select2.js script

 *  Resolved [juliarrr](https://wordpress.org/support/users/juliarrr/)
 * (@juliarrr)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-select2-js-script/)
 * Hi,
 * the problem can be replicated on the current WordPress version on the default
   theme like 2021.
 * When adding several forms on one page (two and more) select2.js script works 
   only for the last one.
 * Please let me know when it will be fixed. Thank you!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-with-select2-js-script%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [Kris – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport13/)
 * (@wpmudevsupport13)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-select2-js-script/#post-14654746)
 * Hi [@juliarrr](https://wordpress.org/support/users/juliarrr/)
 * I hope you are doing good today.
 * This is a known issue in Forminator and our developers already working on a fix
   and this should be fixed in the next update. As for now, there is a temp fix 
   that you can implement on your site as a mu-plugin.
 *     ```
       add_filter( 'forminator_field_single_markup', function( $html, $element_id ){
       	static $select_id;
       	if( false !== strpos( $element_id, 'select-') && preg_match( '/select-([\d]+)-field/', $element_id, $matches ) ){
       		if( $select_id ){
       			$select_id += 1;
       			$html = str_replace( $element_id, "select-$select_id-field", $html );
       		}else{
       			$select_id = intval( $matches[1] );
       		}
       		$select_id ++;
       	}
       	return $html;
       }, 10, 2 );
       ```
   
 * Please save the above code as “select-field-fix.php” and upload it to /wp-content/
   mu-plugins/ folder. Later on, refresh page and issue should be gone.
 * We apologize for the inconvenience
 * Kind Regards,
    Kris
 *  Thread Starter [juliarrr](https://wordpress.org/support/users/juliarrr/)
 * (@juliarrr)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-select2-js-script/#post-14655278)
 * Hi Kris, thanks a lot for your reply!
 * The matter is that this fix doesn’t work for Timepicker and Address fields, it
   works only for the Selectors.
    Could you please provide the solution for all 
   fields? Thanks in advance!
 *  [Predrag – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support1/)
 * (@wpmudev-support1)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-select2-js-script/#post-14658819)
 * Hi [@juliarrr](https://wordpress.org/support/users/juliarrr/),
 * I have forwarded this to our devs to see if there’s a workaround that could be
   applied for other fields until the issue is fixed within the plugin directly.
 * We will update you here once we have further info.
 * Cheers,
    Predrag
 *  Plugin Support [Nithin – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport11/)
 * (@wpmudevsupport11)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-select2-js-script/#post-14668080)
 * Hi [@juliarrr](https://wordpress.org/support/users/juliarrr/),
 * Please try this new snippet instead of the previous code shared and see whether
   it works on your side.
 * [https://gist.github.com/wpmudev-sls/5f3704bcab9cb24c8f18ea0170fb36c9](https://gist.github.com/wpmudev-sls/5f3704bcab9cb24c8f18ea0170fb36c9)
 * The above code can be added as a mu-plugins. Please check this link on how to
   implement the above code as a mu-plugins:
    [https://premium.wpmudev.org/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins](https://premium.wpmudev.org/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins)
 * Please do let us know if you need any further assistance. Have a nice day ahead.
 * Best Regards,
    Nithin
 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/problem-with-select2-js-script/#post-14699383)
 * Hi [@juliarrr](https://wordpress.org/support/users/juliarrr/)
 * I hope you are doing well and safe!
 * We haven’t heard from you in a while, I’ll mark this thread as resolved.
 * Feel free to let us know if you have any additional questions or problems.
 * Best Regards
    Patrick Freitas
 *  Thread Starter [juliarrr](https://wordpress.org/support/users/juliarrr/)
 * (@juliarrr)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/problem-with-select2-js-script/#post-14701664)
 * Thank you, this solution works for us!
    Have a nice day!

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

The topic ‘Problem with select2.js script’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

## Tags

 * [select form](https://wordpress.org/support/topic-tag/select-form/)

 * 6 replies
 * 5 participants
 * Last reply from: [juliarrr](https://wordpress.org/support/users/juliarrr/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/problem-with-select2-js-script/#post-14701664)
 * Status: resolved