AdvancedCustomFields / AdvancedCustomFields/acf

Select2 fields not working with two `acf_form`s on the same page

Open
#627 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Hi!

I've run into an issue with duplicate forms that affects both my own plugin Advanced Forms and the built-in acf_form. The issue occurs when you have two instances of a single acf_form on the same page and the forms contain a select2 field of some kind. In my case, I have a taxonomy field and only the last occurrence of the field is properly initialized:

Skärmavbild 2022-03-17 kl  18 32 13

Steps to reproduce

  1. Create a new field group and add a taxonomy field
  2. Create two forms for this field group on the same page using acf_form
  3. The first taxonomy field won't be properly initialized

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with two acf_form instances containing the same taxonomy or other Select2 field on one page. Trace how acf_form renders the fields and how Select2 initialization targets them; done means both form instances initialize their Select2 fields correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.