Home Forums Add-ons Flexible Content Field Cloned Defaults


Cloned Defaults

  • Hi, hello everybody, i have an issue and i can´t get how to solve. The thing is this:

    – All fields and groups are created using php (no admin, no json)
    – Inside a no active group i put all my reusable fields that will be used on other parts with the field “clone”
    – I have also a flexible field in a group that uses those cloned fieds.

    Ok, so the key names of those fields became longer and complicated, let´s say something like this:



    key__flexible_content_rows is the flexible field
    key__layout_flexible_row__content is the layout inside that flexible
    key__layout_html_row__content the field inside layout (this is type clone)
    key__r_builder_classes_group A field type “group” (this is the cloned)
    key__classes__content_row__container and last, this is the field itself (this is inside the cloned)

    As you can see i have:

    flexible->layout->field (clone)->field (group)->field (text)

    And i´m tring to set defaults for that last text field… and i can´t 🙁

    I tried with:
    add_filter(‘acf/load_field/key=KEY’, ‘my_acf_load_field’);

    But as you can imagine, the KEY it´s imposible, i tried many things and nothing, i cant set default using Key and that filter.

    Is there any thing i´m missing for this cloned defaults?

    I don´t want to set defaults directly on the cloned fields i want to set diferent defaults depending on where i´m cloning that field.

    I´m clear or is too confused?

    Thanks in advance! Sorry my english 🙁

  • That is the field name, use the field key, it looks something like field_123456abcde

  • Hi John, nop, the “key” field is “key__classes__content_row__container”, i named with “key_” my key fields and without “key” the names, so for any field i allways have:

    key: key__classes__content_row__container
    name: classes__content_row__container

    If i apply the filter using the key “key__classes__content_row__container” it apply for any field everywhere, and that´s the thing i don´t want.

    I need to apply a filter to that cloned field but just in that place, not all the cloned fields using that field.

    This is the final field, that´s a cloned one inside a flexible field:

    <input type="text" id="acf-key__flexible_content_rows-5b8d6b7c7ff95-key__layout_html_row__content_key__r_builder_classes_group-key__classes__content_row__container" name="acf[key__flexible_content_rows][5b8d6b7c7ff95][key__layout_html_row__content_key__r_builder_classes_group][key__classes__content_row__container]" value="container" placeholder="container">

    And this is the same field but in another flexible layout:

    <input type="text" id="acf-key__flexible_content_rows-5b8d6cb87ff96-key__layout_template_row__content_key__r_builder_classes_group-key__classes__content_row__container" name="acf[key__flexible_content_rows][5b8d6cb87ff96][key__layout_template_row__content_key__r_builder_classes_group][key__classes__content_row__container]" value="container" placeholder="container">

    The first one is inside “key__layout_html_row__content” (flexible layout)
    Second in “key__layout_template_row__content” (flexible layout)

    If i apply the filter by key using “key__classes__content_row__container”, it applys for all places but i want to apply only for a particual place, let´s say the first one.

    I know it´s very complex my situation….

  • Hi John, nop, the “key” field is “key__classes__content_row__container”, i named with “key_” my key fields and without “key” the names, so for any field i allways have:

    Field keys must start with “field_”, if your using “key_” then that’s probably part of your problem.

    It’s easy to miss in the field settings section

    $field = array (
    	/* (string) Unique identifier for the field. Must begin with 'field_' */
    	'key' => 'field_1',
  • Whow, i´m using ACF since the begining of times and i never saw that part of the “field_” for the key values!!! My bad 🙁

    Thanks so much John!!!

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

The topic ‘Cloned Defaults’ is closed to new replies.