Support

Account

Home Forums Add-ons Repeater Field Repeater's Big Problem :((( , Please read it!! – thanks a lot ^^

Solved

Repeater's Big Problem :((( , Please read it!! – thanks a lot ^^

  • I have searched all possible places on the internet. But it is not possible to find a satisfactory answer to the ACF Field Naming Rules in the most clear, detailed, and understandable way.

    With my particular case. I want to name the subfield of ACF Repeater.
    My question is: Can I give SubField common names like: Title, Image… without including the SubField’s parent name? For example: Parent_Child Field – or do I just need to name Child for the Sub Field???

    I see ACF saying that Subfield names should be as simple and concise as possible. But I am afraid that in other groups of fields, it will be easy to cause duplicate names such as: Title, image…. if they stand alone in the Subfield.

    I’ve also read some comments that say the same subfield name can be used for multiple groups and pages.
    But there are also other comments that say, if using subfields of the same name in the same page or different sets of fields. Will cause overwriting, field inaccessibility and data corruption ???…..

    So there were a lot of conflicting opinions and it made my head explode.

    Please help me to explain and give the most accurate and easy to understand answer

    Thank you very much, and wish you all the best and happiness

  • Yes, repeater sub fields can be simple like “title” and can be duplicated in multiple repeaters.

    The only limit to field names is naming sibling fields the same. All sibling field names must be unique.

    What does that mean?

    First it means that all “Top Level” fields in all field groups used on the same editor page must have unique.

    It also means that all sub fields of the same parent must be unique.

    Fields that have different parents, with unique field names do not need to be unique.

  • Hello, Mr. John Huebner. Thank you sir for your prompt reply and very valuable to me at this time. I think I understood 80% of the answer.

    But please understand that, I am a Korean, English is not the main language, and I am afraid that I am misinterpreting, or not fully understanding, your explanation correctly.
    So I would like to give a specific example below. And hope you can answer me, is it right or wrong:

    1.I create 2 Field Groups: (A Field Group) and (B Field Group)

    2. Then I point (A Field Group) to CPT (custom post type) which is MOVIE
    and point (B Field Group) to CPT as MUSIC

    3. Finally I create 2 Single Post in Elementor with same name MOVIE and MUSIC

    :- At (A Field Group) I created a Repeater Field with the name “Banner”
    Then I create the Sub-Fields of “Banner” as: Title and Image
    :- And at (B Field Group) I created a Repeater Field with the name “Catalog”
    Then I create the Sub-Fields of “Catalog” as: “Title” and “Image”

    **** Thus (2 Repeater Field: Banner & Catalog) of (2 Field Group: A & B) All have Sub Fields named: “Title” and “Image”

    :— According to Mr. John Huebner’s explanation, is this the case allowed???? When the subfields are the same, but the names of the Repeater Field parents are different???

    But I get very serious errors in Elementor when using a Plugin to call Repeater Fields Dynamic.ooo (Because Elementor doesn’t support Repeater Field yet)

    The error is when the Sub Fields have the same name between 2 Field Groups (or 2 parent fields are Repeater Field: Like Banner & Catalog).

    :— Then the errors encountered are: 2 Repeater Field Banner & Catalog, will not be able to fully display both, but one side will disappear and cannot be found and called out.

    Can you help me answer. This error belongs to Dynamic.ooo – ACF or Elementor??? They make me very tired to see where I am going wrong, and having to name the Sub Field the same, makes the situation worse.
    I’d love to keep the name short and not include the parent’s name in the sub field. But when using a common name like Title for Repeater Fields in different Field Groups, they often can’t be found or the error doesn’t show up in Elementor’s Dynamic.ooo.

    It took me a whole month to figure this out and the best solution. But the experts they couldn’t answer either.

    Please help me Sir John Huebner. I will be very grateful to you ^^.
    Thank you for everything, looking forward to your best explanation. Wishing you all the happiness and luck in life

  • :β€” According to Mr. John Huebner’s explanation, is this the case allowed???? When the subfields are the same, but the names of the Repeater Field parents are different???

    Yes, this is allowed

    But you are using elementor, I can’t help you there.

    All I can tell you is that you need to provide ACF with the Post ID to get the field values from. Since you are using a 3rd party plugin (Dynamic.ooo) to integrate with another plugin(Elementor) the people you should be asking about his is probably Dynamic.ooo.

  • Thank you very much Sir John Huebner, I feel like a pain is released. I want to give you my sincerest thanks ^^ <3<3 You are so lovely

  • I got this answer also from ACF support itself. But it seems to contradict the expert John Huebner’s answer above?

    So the final answer to this is: it is possible to name the child fields the same, as long as it is unique in a parent field.
    But then it should not be named the same subfield in any case on the same page or in different groups. Because they can cause errors????

    So which is the correct one? Even the ACF rep has me baffled πŸ™

    Because the field naming is simple and the same as Tile, Image – will be very different from prefixing each subfield.
    I just want to know what is actually correct and does not lead to future errors or crashes. If naming the same subfield on a page or in a different group would result in an error, then why does ACF allow that simple and identical naming?

    Chris Mucheke (WP Engine Support)

    Hi there,

    Thanks for reaching out to us, I trust you are keeping safe!

    When it comes to naming ACF subfields for repeaters, it is generally recommended to use simple and concise names that describe the content of the subfield. You can name the subfields as Title, Image, etc. without including the parent field name, as long as these names are unique within the repeater field.

    However, if you have multiple repeater fields with the same subfield names on the same page, it can lead to data corruption and accessibility issues. To avoid this, it is a good practice to prefix the subfield name with the repeater field name, for example, if you have two repeater fields with a subfield named “Title”, you can name them as “Repeater1_Title” and “Repeater2_Title”.

    In addition, it is recommended to avoid using the same subfield names across different groups of fields, as it can also lead to data corruption and field inaccessibility. Instead, try to use unique names that describe the content of the subfield.

    To summarize, when naming ACF subfields for repeaters, use simple and concise names that describe the content of the subfield. If you have multiple repeater fields with the same subfield names on the same page, prefix the subfield name with the repeater field name to avoid data corruption and accessibility issues. And, avoid using the same subfield names across different groups of fields to prevent data corruption and field inaccessibility.

    Hope that all helps, please let me know if anything needs clarification.

    Kind Regards,

    Chris

  • I don’t think they are saying anything different. What is important is keeping the meta key in the database unique for any WP object. For example, for a post, term, user, options.

    This is how meta keys are determined and all the entries you will find in the DB

    Top Level Field (field that is not a sub field of another fields) All top level fields stored for the same type of WP object must be unique: "{$field_name}";

    Sub fields of a repeater, this includes repeaters and flexible content: "{$repeater_field_name}" AND "{$repeater_field_name}_{$row_index}_{$sub_field_name}"

    Group Fields, group fields are a special kind of repeater that always has exactly 1 row: "{$group_field_name}" AND "{$group_field_name}_{$sub_field_name}"

    Clone Fields: Clone fields are more complicated because how they are stored is determined by the display setting. When using “Seamless Display” Cloned Fields work like top level fields or like sub fields of the type of parent field they are cloned into. When using “Group” display fields in them work like sub fields of Group Fields.

    Everything can be nested, for example if you have a field that is in a repeater and the repeater is in a group field and that group field is a sub field of a flex field then the field key of the final field would be

    
    "{$flex_field_name}_{$row_index}_{$group_field_name}_{$repeater_field_name}_{$row_index}_{$sub_field_name}"
    

    As you can see by the above, with a unique top level field name there should never be a conflict and as long as the top level field name is not duplicated on the current WP Object, there should not be a conflict.

    With top level repeater fields of different names and/or fields stored for multiple things like one field on a term and one field on a post there are 2 things that can cause them to go wrong when using them in the same template.

    1) Using the second repeater before you are done looping over the first repeater. This will cause ACF to loose track of the first repeater when the second loop begins.

    2) Not specifying the correct $post_id when starting the loop over a repeater.

    Because you are using elementor I cannot tell you if either of these 2 things are happening. But what I can tell you is that you will have an extremely difficult time displaying fields for a post on template designed for a term and you will have a difficult time displaying fields for a term on a template designed for a post.

    On a term template (archive) the correct $post_id must be supplied for both the post and the term. ACF should be able to determine the Post ID of the post if you are in a loop over the posts. The $post_id of the term must always be specified.

    On a post template (single post) the $post_id for the term ACF will be able to determine the post ID of the current post. The $post_id of the term must always be specified.

  • This reply has been marked as private.
  • This reply has been marked as private.
  • I really appreciate your detailed answer for me.

    People who had the same question certainly had the correct answer for them.
    But I’m a fool in faraway Korea, please forgive me for that ^^!

    So I want to ask you one last question, and I won’t bother you again. So that I can be sure that I understand correctly.

    {According to your explanation: I can understand that I can still use the same Subfield Names – in Groups and Repeating Senior Fields provided these Parent Fields are named Unique. best???}

    And is this allowed and legal in ACF?

    The display errors you’re warning about, are only encountered when using with Elementor right? (Actually I’m also getting an error about not showing the same subfield names on the same page on Elementor, but when selecting the correct parent field, then selecting the child field name, even though it’s in the other high level, it still shows properly: Specifically 1 Subfield named Image located in 3 Repeated fields A, B and C, but when I search, it shows only 1 subfield named Image in the field high-level group C. But when selecting the Parent Group Field as A, then selecting the Image link in the group C field, it still returns the correct result as the image of the Image subfield in group A)

    And so, in essence, using the same Subfield Names in the Group and Repeat top-level fields, is correct and correct with the ACF stipulation? the errors shown above are encountered only when combined with Elementor?

    With my many long and stupid questions. You can simply answer YES or NO! ^^
    Although I am still confused and would like your advice should I decide to use the same and simple Subfield Names for many other subfields or should I prefix the subfields so that they are unique and avoid the possible error as you warned.

    Because having to prefix the child field names of all groups and repeating parent fields would become very complicated for me. (Since my project is very large and has many SCHOOL GROUPS), even adding prefixes to subfields will still result in the same name as other subfields in other Field Groups. And if it is required to include more layers of prefixes like: prefix1_prefix2_prefix3_subfields to create uniqueness for subfields, that would be a real nightmare for me πŸ™ – because it would get very long and feels like it’s the wrong way:
    For example, 1 repeating parent field named Homepage_Gallery and 1 subfield Homepage_Gallery_Image (And when I search for the Image subfield on Elementor it will be the string Homepage_Gallery_Homepage_Gallery_Image – it gets very complicated and elusive, though in the reality I’ve encountered will have many layers of lower-level subfields and their string visualizations to be complicated and nightmarish…)

    I may be fired if I don’t solve this most correct subfield name selection, please help me πŸ™ πŸ™ πŸ™

    Looking forward to receiving your comment or reply YES or NO.
    Thank you for listening and wish you all the best, kind person!!

  • SIR JOHN HUEBNER

    Please help me answer this conundrum about ACF Field. I have searched in many places but there is no answer, I can only hope in this place.

    Question: Should I name the SubField of the Repeater Field a simple separate name like: Title, Image… or should I include the parent field in it like: Parent_Subfield???

    Case 1: If I name Subfield as a simple name that does not include parent fields like Title, Image… but they will overlap and be the same as Subfield names in other groups of fields with the same subfield as Title, Image. … I’m afraid this will cause an error because ACF recommends that field names should be unique.

    Scenario 2: If I set a Subfield with a name that includes the parent field name along with a child field like parent_subfield – then I should be able to create unique field names and not confuse subFields in other field groups. But the problem here is that if used together with the parent field name in the child field, it will make the field name sometimes very long and confusing (especially with many layers of field groups and many repeating fields with subfields in the field). my project)
    Example: Field group name is Movie – group field is Video – repeat field is Hero Banner – Subfield is will be Image
    Then the name of the Image field will be movie_movievideo_movievideoherobanner_image

    It is very long and very confusing!

    I hope I have described it clearly enough for you to understand this dilemma
    So please give me the best solution for this?
    Once again I would like to thank you very much ^^

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

You must be logged in to reply to this topic.