Skip to content

Conversation

@jasonbahl
Copy link
Contributor

@jasonbahl jasonbahl commented Dec 29, 2023

What does this implement/fix? Explain your changes.

This fixes a bug where the "taxonomy" field will return an error when queried if the field is set to not allow multiple selections, but has multiple selections stored.

This can happen when the field was configured to allow multiple selections, had data saved, then is later changed to be a single select, but the stored data is still multiple values in an array.

Does this close any currently open issues?

Related to #133

Any other comments?

  1. Create a "Taxonomy" field on an ACF Field Group assigned to an ACF Block
  2. Set the field to "Multi Select"
  3. Edit the block using the field, selecting multiple terms

CleanShot 2023-12-28 at 19 56 55

  1. Save the content

Here we can see 2 terms are saved:

CleanShot 2023-12-28 at 19 57 22

  1. Change the field back to "Select" (to only allow 1 value) but leave the content as-is, with 2 terms stored as the field's value.
  2. Query for the field

BEFORE

There's an error:

CleanShot 2023-12-28 at 19 53 48

AFTER

No error, but the response only contains 1 item

CleanShot 2023-12-28 at 19 55 38

Which matches the UI of the Block now, and if the block is saved again will only save 1 value instead of multiple:
CleanShot 2023-12-28 at 19 56 13

@jasonbahl jasonbahl self-assigned this Dec 29, 2023
@jasonbahl jasonbahl changed the title Fix/#133 taxonomy field on blocks fix: #133 taxonomy field on blocks Dec 29, 2023
@jasonbahl jasonbahl merged commit 250b4e2 into develop Jan 8, 2024
@jasonbahl jasonbahl mentioned this pull request Jan 23, 2024
@jasonbahl jasonbahl deleted the fix/#133-taxonomy-field-on-blocks branch January 24, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants