AdvancedCustomFields / AdvancedCustomFields/acf

Disabled Flexible Content layouts create field overrides

Open
#994 6 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

Describe the bug
In a Flexible Content, when calling the field before and disabling one of the layout and if you have successive layouts with similar field names, empty fields are override by the previous layout fields content.

To Reproduce
Steps to reproduce the behavior:

  • In a Flexible Content (field name flexible_content), have at least two different layout type with optional fields :
    • Layout 1
    • Layout 2 (optional fields: title, text)
  • Add the layout in the flexible content :
    • Layout 1
    • Layout 2 (fill title and text fields)
    • Layout 2 (let title and text empty)
  • Disable Layout 1

The second Layout 2 should have the title and text of the previous one.

Before calling the Flexible Content render loop, call get_field('flexible_content') (e.g. in a init wp hook for preprocessing)
The layout are rendered in the usual have_rows loop and the layout field with get_sub_field.

Expected behavior
Layout field should not override

Version Information:

  • WordPress 6.9
  • PHP 8.3.0
  • ACF 6.7.0.2

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 get_field('flexible_content') called from an init hook, then render the layouts with have_rows and get_sub_field. Compare successive Layout 2 rows after disabling Layout 1; the work is done when empty title and text fields remain empty instead of inheriting the previous row's values.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.