Support

Account

Home Forums ACF PRO Clone Fields and Recursion

Solving

Clone Fields and Recursion

  • ==== Updated Question with Minimal Reproduction ====
    ACF ExportScreenshots

    I have a Flexible Content field that has layouts that clone the flexible content field. However I cant add a layout to any layout that is the same type without it breaking.

    Please see images.

    ===== Original Question Follows =====
    ACF export: http://pastebin.com/raw/LG5jCSDG

    Screenshots: http://imgur.com/a/mRBEw

    So I’m trying to make a page builder using clone fields. I’m using the bootstrap framework so I have a flexible content field ‘Elements’ with types: container, row and column, along with my custom content elements (in this example, just a WYSIWYG element).

    The container, row and column elements have a clone field of the top level ‘Elements’ flexible content field to allow a recursive builder (putting elements inside of other elements without having to redefine all the elements).

    It works fine with:

    • Container
      • Row
        • Column
          • WYSIWYG

    or

    • Container
      • Row
        • Column
          • WYSIWYG
        • Column
          • WYSIWYG
    • Container
      • WYSIWYG

    but as soon as I add something in to itself so to speak…

    • Container
      • Row
        • Column
          • Row

    or the more simple (ignoring that this would be invalid bootstrap)

    • Container
      • Container

    It breaks, and doesn’t show (some of) the cloned fields.

    Am I just asking too much, or doing something wrong?

  • “The have_rows() function will return false when loading a cloned sub field using the ‘Display = Block’ setting. Please note that using the ‘Seamless’ display setting will allow sub have_rows() loops to work as expected.”

    https://www.advancedcustomfields.com/resources/clone/

    I hope an update will “fix” this.

  • Hello Mr Fischer, I don’t think you’ve understood my problem correctly.

    I haven’t even got to the point of saving the page, never mind trying to load fields.

  • @first4websites Did you manage to find any solution for this? I’m having the same issue.

  • @tpeleg No, sorry, didn’t manage to find a solution. Below is the response I got to the support ticket I submitted… I replied (on 28th Oct) clarifying that I hadn’t even gotten to the point of saving to the database and haven’t had a response…

    James Stout replied
    Hi There,

    Thanks a lot for the mail,

    ACF uses the field’s name (see field settings) to save a value into the database. When saving sub fields, the ‘save name’ is generated by the ancestors names + the row index and can become quite long. It is possible that the length of this ‘save name’ can become too long for the wp_options table, and WP will not be able to save the value at all.

    Kindly try creating a duplicate filed for use inside the layout and let me know if the problem persists.

    Hope to hear from you soon.

  • I’m a little confused with your explanation. Are you trying to include the field group in itself by cloning it? This would create an infinite loop. It appears that as soon as ACF tries to include the cloned clone it stops. You cannot re-clone the same fields endlessly and it appears that ACF stops when you get to the second recursion, which makes sense to me.

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

The topic ‘Clone Fields and Recursion’ is closed to new replies.