Support

Account

Home Forums Search Search Results for 'reusable group'

Search Results for 'reusable group'

topic

  • Solved

    ACF 6 + Timber renderCallback not working in editor

    I’m having a similar issue to this ticket. I’m using ACF and Timber with a renderCallback function. This works fine and seems to load the template on the front end but doesn’t seem to work in the editor. I get ‘Your site doesn’t include support for the “acf/[blockname]” block. You can leave this block intact or remove it entirely.’ errors in the editor even though the blocks load on the front-end. It even pulls in the field data that existed before I switched to block.json on the front-end only.

    /button/block.json

    {
      "name": "acf/button",
      "title": "Button",
      "description": "A button block.",
      "category": "dream",
      "icon": "button",
      "keywords": ["button", "buttons", "button group"],
      "attributes": {
        "blockId": {
          "type": "string"
        }
      },
      "usesContext": [ "buttonGroup/blockId" ],
      "supports": {
        "jsx": true,
        "align": true,
        "alignContent": true,
        "alignText": true,
        "anchor": true,
        "className": true,
        "multiple": true,
        "html": false,
        "inserter": true,
        "color": {
          "text": false,
          "background": true,
          "link": false,
          "gradients": true,
          "linkColor": true
        },
        "fontSize": true,
        "fullHeight": false
      },
      "styles": [
        { "name": "default", "label": "Default", "isDefault": true },
        { "name": "other", "label": "Other" }
      ],
      "editorScript": "file:./index.js",
      "script": "file:./script.js",
      "editorStyle": "file:./index.css",
      "style": "file:./style.css",
      "acf": {
        "mode": "preview",
        "renderCallback": "dream_block_render",
        "postTypes": true,
        "parent": "acf/button-group",
        "reusable": true
      }
    }

    I also get a js error in the console when editing pages whether or not blocks exist on the page:

    acf-pro-blocks.min.js?ver=6.0.3:formatted:783 Uncaught TypeError: Cannot read properties of undefined (reading 'length')
        at _ (acf-pro-blocks.min.js:783:51)
        at Array.map (<anonymous>)
        at acf-pro-blocks.min.js?ver=6.0.3:1419:24
        at o (acf.min.js?ver=6.0.3:1:1417)
        at Object.doAction (acf.min.js?ver=6.0.3:1:587)
        at n.doAction (acf.min.js?ver=6.0.3:1:18745)
        at post.php?post=1521&action=edit:3223:5

    Looks like it may be related to the “attributes” key so maybe I’m just doing something wrong but I’m unsure.

    Line 783 of acf-pro-blocks.min.js

    for (const t in e.attributes)
                        0 === e.attributes[t].default.length && delete e.attributes[t].default;
                    e.supports.anchor && (e.attributes.anchor = {
                        type: "string"
                    });
  • Unread

    Duplicated ACF Blocks in Widgets failing to save/render correctly

    ## Issue
    When duplicating an ACF block (registered with acf_register_block_type) data between the blocks can switch place and/or regress. Repeater fields and expander toggles stop working. No javascript error is shown in console.

    ## Environment
    PHP 7.4.21
    WP 5.8.1
    ACF Pro 5.10.2

    ## Reproduce
    1. Create ACF Field Group

    
    acf_add_local_field_group(array(
    	'key' => 'group_614c3a15115de',
    	'title' => 'Test Block',
    	'fields' => array(
    		array(
    			'key' => 'field_614c3c7d9b75e',
    			'label' => 'Test Field',
    			'name' => 'test_field',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    	),
    	'location' => array(
    		array(
    			array(
    				'param' => 'block',
    				'operator' => '==',
    				'value' => 'acf/test-block',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'acf_after_title',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => true,
    	'description' => '',
    	'is_acf_component' => 0,
    	'acf_component_defaults' => array(
    		'repeatable' => '0',
    		'min' => '',
    		'max' => '',
    		'layout' => 'block',
    		'button_label' => '',
    		'appearances' => '',
    	),
    ));
    

    2. Register ACF Block

    
    acf_register_block_type(array(
    	'name' => 'test_block',
    	'title' => __('Test Block'),
    	'description' => __('Test Block'),
    	'render_template' => 'template-parts/content_builder-test.php',
    	'category' => 'formatting',
    ));
    

    3. Create template file in render_template location with the contents: <?php the_field('test_field');
    3. Navigate to Widgets wp-admin/widgets.php
    4. Add new ‘Test Block’
    5. Duplicate ‘Test Block’ a few times.
    6. Edit the contents of the fields, toggle between Edit/Preview.

    ## Expected Result
    All fields and admin elements should work as normal.

    ## Actual Result
    The preview does not align with the content, when switching back to edit, the value in the field may have changed too. The ‘Update’ button often is not triggered to an active state. When managing to save, reloading shows the widgets in a different state to when you left it.

    ## Extra
    Copying the contents into a reusable block, editing then copy/pasting back in does not work. (Reusable blocks are not supported in the Widgets interface just yet.)

    ## Work around
    Create all blocks from scratch within the widgets interface.

    Thank you.

  • Unread

    Duplicated ACF Blocks in Widgets not saving

    Issue
    When duplicating an ACF block (registered with acf_register_block_type) data between the blocks can switch place and/or regress. Repeater fields and expander toggles stop working. No javascript error is shown in console.

    Environment
    PHP 7.4.21
    WP 5.8.1
    ACF Pro 5.10.2

    Reproduce
    1. Create ACF Field Group

    
    acf_add_local_field_group(array(
    	'key' => 'group_614c3a15115de',
    	'title' => 'Test Block',
    	'fields' => array(
    		array(
    			'key' => 'field_614c3c7d9b75e',
    			'label' => 'Test Field',
    			'name' => 'test_field',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    	),
    	'location' => array(
    		array(
    			array(
    				'param' => 'block',
    				'operator' => '==',
    				'value' => 'acf/test-block',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'acf_after_title',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => true,
    	'description' => '',
    	'is_acf_component' => 0,
    	'acf_component_defaults' => array(
    		'repeatable' => '0',
    		'min' => '',
    		'max' => '',
    		'layout' => 'block',
    		'button_label' => '',
    		'appearances' => '',
    	),
    ));
    

    2. Register ACF Block

    
    acf_register_block_type(array(
    	'name' => 'test_block',
    	'title' => __('Test Block'),
    	'description' => __('Test Block'),
    	'render_template' => 'template-parts/content_builder-test.php',
    	'category' => 'formatting',
    ));
    

    3. Create template file in render_template location with the contents: <?php the_field('test_field');
    3. Navigate to Widgets wp-admin/widgets.php
    4. Add new ‘Test Block’
    5. Duplicate ‘Test Block’ a few times.
    6. Edit the contents of the fields, toggle between Edit/Preview.

    Expected Result
    All fields and admin elements should work as normal.

    Actual Result
    The preview does not align with the content, when switching back to edit, the value in the field may have changed too. The ‘Update’ button often is not triggered to an active state. When managing to save, reloading shows the widgets in a different state to when you left it.

    Extra
    Copying the contents into a reusable block, editing then copy/pasting back in does not work. (Reusable blocks are not supported in the Widgets interface just yet.)

    Work around
    Create all blocks from scratch within the widgets interface.

    Thank you.

  • Solved

    Seamlessly clone a group field but allow changing its name and having unique key

    Let’s say I have a field group called “Call To Action” with the name “cta”. This group contains a Text field, a URL field, and a checkbox called “Open in new window”.

    I also have a Home Page field group that needs this “Call To Action” group cloned into the Hero tab, the Content Teaser tab, and the Promo tab. If I choose “Seamless” as the cloning method, I will have 3 field groups labeled “Call To Action”, which is great. But these groups will all be named “cta” and have the exact same field key, which obviously will cause problems. If I choose “Group” as the cloning method, it will nest my “Call To Action” group into another group, which I do not want.

    Cloning could be a very useful feature for creating reusable groups (that act like modules), but this limitation of not being able to specify a custom name when using “Seamless” makes it very limited. If I want all of my “Call To Action” fields inside a group with a unique name and key, I need to use the “Group” cloning mode and select each individual field to clone into it. Later, if I decide to add another field into the master “Call To Action” group, I would need to go to every clone instance and add that field into it. That really takes away a major advantage of creating reusable elements (being able to edit all instances in a single place).

    If we could input a custom field name when using the “Seamless” cloning mode, that would make these fields so much more useful as a templating tool. Or maybe there’s a way to do this that I’m missing?

  • Solving

    ACF Blocks issue when made "reusable"

    I have created a ACF block called “services” that contains a repeater field and a few other sub fields to display my customer’s services.

    When I choose to “add to reusable blocks” I get a little bit of a strange behavior.
    Reusable blocks add a wrapper around the original block. So your original block is nested inside of this new container

    My original block is visible with the content that I originally added. However when I deselect my block and attempt to save the reusable block, I see that the reusable block has a second version of my repeater fields, empty and ready to fill in.

    In case that is unclear, I’ll describe it in this way: two versions of the ACF field group are being added. One at the level of reusable block, and one at the level of the custom block.

    To replicate:

    • Create a custom block (set the mode as “preview” so the editing takes place in the sidebar) and add content to your new block.
    • “add to reusable blocks”
    • save and refresh your page
    • click on the reusable block and select “edit”
    • click on your reusable block and make an edit
    • deselect your reusable block and click on the save button at the reusable block level
    • It won’t save, instead look in the sidebar and you will see another set of empty fields
    • click on save again… and this time it should actually save.
  • Solved

    Which rules should I set for a reusable Field Group (using as a Clone field)

    I have a field group that I include in other field groups as a Clone field. For example, one of my field groups is called “Page Banner”. In every field group I want a page banner, I include the “Page Banner” field group as a Clone field.

    My question is, in the “Page Banner” field group’s Rules, what can I set the Rules to so that it doesn’t appear on any page? (Unless I add it as a Clone field of course.) The default rule is “Show this field group if <Post Type> <is equal to> <Post>”. But I don’t want this group appearing on every “post” post type. So what can I set the rules to so that it doesn’t appear anywhere, unless I “embed” it as a Clone field?

  • Solved

    Assign a fields group to nothing at all

    Hello everyone !
    New here, I was pretty sure this was not a bug, so I posted in “Feature Requests”, but just tell me if there is a better Forum Category for this post !
    So I’m trying new acf guidelines with my team, and part of it is to have a “Common Fields” fields group, wich contains group type fields (hard to follow ? I know, sorry), one for each of our many reusable design components around the websites. After that we use clone everywhere we need these components.
    Anyway, enough spaghetti context, this group field called here “Common Fields”, is not meant to be used as it is in any way, so I wish I could assign it to nothing, but I can’t. (or didn’t find the way)
    Thanks for reading,

    hugo

  • Solved

    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:

    “acf-key__flexible_content_rows_key__layout_flexible_row__content_key__layout_html_row__content_key__r_builder_classes_group-key__classes__content_row__container”

    Where:

    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 🙁

  • Helping

    Flexible Field: Ajax Save & Deactivation

    Hi there,

    i’m working a lot with the flexible Content field on different projects and created reusable “Modules” which i use in this projects.

    However, i often don’t need some Modules of my Library for the current project, so an option to deactivate a Flexible Module/Layout would be nice. So the Module is still there, to be activated when needed, but doesn’t clutter the CMS for the customer. You can deactivate the whole Flexible-Field-Group, but thats not whats needed here.

    Another great improvement would be Ajax-Saving the Flexible Fields on creation. Everytime we save, the Page is refreshed now, which closes all Flexibles Fields. When i have to change something in a Layout-Field, i first have to find my way through the fields to reach it, which gets tedious after a while.

    best regards,
    Alex

  • Solving

    Importing Flexible Content fields causing issues

    Really not sure what’s going on here. I am trying to to an import from my local install to live site and am running into very strange problems with some flexible content fields. I have a number of layouts, most of which contain some repeaters. None of the sub fields for the repeaters are importing, and only the first 7 our of 11 layouts are importing.

    Now I already had this field group set up on the live site with 7 layouts setup. But after doing some reworking locally, I deleted the old field group and tried to import. The strange thing is that the 7 out of 11 layouts that are actually importing are the same layouts that were in the old field group. None of the new layouts are importing, and again none of the sub fields on any repeaters are being imported.

    I am also using the following extension, but I’m not sure if this is related to the problem: https://github.com/Hube2/acf-reusable-field-group-field

    Attached is the json for the field group I am having trouble with. Has anyone experienced something like this before?

  • Solving

    Create a generic "group" layout field type

    Looking to create a simple field type that is just a grouping of multiple sub fields — similar to the “Repeater field”, except that it doesn’t need to repeat.

    The reason I want this is for general organization. It’ll give me more flexibility with the layouts that I’m trying to create.

    I started to build this with the “Repeater field” sourcecode, and had everything was displaying as I wanted it, but the saving was not working. I suspect that using the repeater field is probably overkill, so maybe I’m just over-complicating this.

    I should also note that I was able to accomplish the same layout I am looking for by using the “Reusable field” addon (https://github.com/tybruffy/ACF-Reusable-Field-Group), however, since the fields aren’t actually contained in the same field group, there is no way to use them in conjunction with conditional logic, and this plugin breaks when trying to use it inside of a Repeater field.

    Any ideas on how I can accomplish this would be great!

  • Solving

    Reusable Modules in Flexible Content

    The problem:

    I have a content box module where I can add one or several content boxes. But I want these nested in various layouts. Such as a fullwidth layout or a fullheight layout for example.

    But whenever I create a new layout type in Flexible Content I have to set up the Content Box module (field group) again although they share the same settings and characteristics.

    The question:

    Is it possible to create a module (field-group) that is reusable and edited separately so whenever I change any settings for the module I just have to change it i one place?

  • Helping

    Hide Certain Labels in ACF

    Hi,

    Is it possible not to display a label in ACF? On a field by field basis.

    I’m using the reusable field group plugin (https://github.com/tybruffy/ACF-Reusable-Field-Group) and it’s duplicating labels.

    Thanks,
    Andy.

  • Solved

    Creating theme fields – generating a key?

    I’m interested in the possibility of defining a set of custom fields in php and then adding them to various different groups as needed. For example, I need an address field in a lot of different groups and it has lots of sub-fields and layouts. This would also help maintain consistency of formatting and naming when using those fields on the frontend.

    The method for generating theme fields I have seen so far in the forums is based on exporting to php, then including that code.

    However, that produces (depending on the complexity) a somewhat massive multi-dimensional array that is very hard to read or edit.

    The only problem with my idea is that I don’t know anything about the unique field keys that are generated. I couldn’t find the function that generates them, and I don’t know if the unique character string has any relationship to the rest of the field definition (is it a hash of some of the array elements, for example?)

    Can anyone tell me if they’ve done this, and if so how and what issues should I be aware of? Or what is the best method you can suggest for defining reusable fields?

  • Solving

    Reusable Field Groups

    I think it’d be awesome to register a field group, but to be able to use that group within another group elsewhere.

    Example:

    I’ve got various similar field groups for various post types, it’s not appropriate to have one field group to cover them all, however there is a small sub-set of reused fields.

    Rather than having to duplicate this sub-set of fields it’d be awesome if they could be register as a group of their own, but then called in.

    That way they’re registered just once, so updating them in the future is easy.

    I currently achieve this by registering the fields in code… but I dislike this method vs the ACF field builder.

  • Solved

    Reusable Fields

    Say I have a select field with a list of colors to choose from. I’d like to be able to reuse the list of colors in multiple custom field groups. The point being it’d be managed by one instance.

    As far as I can tell, the only way to do this now is to just create a duplicate select field (which is a pain because I have to manually create them all). And then if they ever change, I need to go edit them all. Ideally, I could create once, reuse wherever in different custom field groups, edit from one instance.

    This doesn’t seem to warrant creating a custom field type, but it’s somewhat related. Perhaps a field type of custom field group. Then it would let me select from the saved field groups and just bring in an instance of that group. Is this a possibility?

reply

  • As this remains the thread that ranks in search engines for “Reusable field group ACF”, it might be nice to mention the following here:

    Version 5.4 will include a new “Clone” field.

    – From John Heubner’s preliminary work on https://github.com/Hube2/acf-reusable-field-group-field

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

  • if i dont missunderstood what @semlohj wish it is already possible:
    at backend primary with the help of the clone-field.
    for the frontend with help of includes that contains the reusable block.

    • create option page, that dont need to be accessible for general / by menu
    • create a fieldgroup with all needed fields inside (everything inside repeater but not repeater itself) assign it to that optionpage
    • create new fieldgroup with repeater and add a clone field that use all field from above group
    • create an other fieldgroup/repeater-field/flexible-field and add a clone field that use all field from above group

    with help of that, you can update the original fieldgroup and the changes apply to the clones

    i do for example:
    fieldgroup teaserbox = text,textarea,image,link
    fieldgroup halfcolum = flexible-field with a layout, that include clone-field:teaserbox
    fieldgroup fullcolumn = flexible-field with a layout, that include a repeater with clone-field:teaserbox inside
    fieldgroup content = flexible-field with 2 layout, one inlude clone-field:fullcolum || the other include prefixed clone-field: halfcolumn, prefixed clone-field: halfcolumn

    now i can add another field to teaserbox and fullcolumn, left_halfcolumn, right_halfcolumn where updated

    hope that help. else may @acf-support can reproduce what i say and give a more detailed answer

  • Thanks for that Script!
    It works great, but I have problems with saving the dragged layouts.
    All layouts, which were dragged to the other fields, are lost after saving the post.
    Have/had somebody the same issue?

    I changed the JS to this for just dragging the layouts between the reusable fields:

    
    connectWith: [
        '[data-layout="1_col"] .values',
        '[data-layout="2_col"] .values'
    ]
    

    I created a field group for all my modules. This field is reused in the columns as an flexible content field:

    - flexible content for modules (using this fieldgroup for reusable field group)
      - text
      - image
      - ...
    

    in the main groups:

    
    - flexible content (1 col)
      - col: reusable field group (flexible content)
    - flexible content (2 cols)
      - first col: reusable field group (flexible content)
      - second col: reusable field group (flexible content)
    

  • My biggest issue is during the image upload process. My current implementation is as follows:

    Flexible Field
    – Layout
    — Flexible Field
    — WYSIWYG
    — Image Upload
    — Plain Text

    The Layouts are 1,2,3,4 columns etc… so each column could use WYSIWYG, image or plain text options.

    Right now I have ACF PRO 5.4.8, am using @hube2 Reusable Field Groups plugin along with some others that I’ve included in the below zip.

    So far I’ve switched WYSIWYG to text tab default (trying @3pointross plugin :), switched from using image object to ID, use no conditionals in the front end. Around image number 5 being added to a column row, I get exceptional page lag.

    I completely understand limiting the complexity of flex content fields, but really want ACF to work as it’s a great plugin @elliot

    UPDATE Have to abandon ACF on a current client site. They experience timeouts when creating rows. I’d love a concrete solution here, but Beaver Builder is going to have to replace for this project.

  • Hi James,

    I appreciate your response and suggestions.

    While the Reusable Field Group looks a really decent option, I am reluctant to go ahead and even experiment with this due to the following issue:

    https://github.com/Hube2/acf-reusable-field-group-field/issues/29

    The above issue is a heads up stating that Elliot has begun work on similar functionality. This sounds great! I completely understand it’s impossible to give any kind of ETA for this work to be ready, but, would you be able to give me an idea of the timescale? Will it be weeks or months?

    Registering fields via php looks the best option for me as the plugin stands now. I understand how this can be done and I appreciate the link providing (the docs are amazing on the page!).

    The only question I have regarding registering fields via php is about naming conventions for field group’s and field keys.

    Do I need to follow the ACF naming convention, or can I use my own just as long the the keys are unique?

    Thanks again,
    Paul

  • Hi @kitt

    I’m not sure what you can do with Page Builder, but there’s a plugin created by John that allows you to duplicate field groups for ACF Pro. Please take a look at this thread to learn more about it: https://support.advancedcustomfields.com/forums/topic/reusable-field-groups/. I’m not sure if it will work with your situation, but I guess there’s no harm in trying it.

    Another method would be registering the fields by using the PHP code. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/register-fields-via-php/. With this method, you can create the required layouts as variables and then add them to the right place programmatically.

    I hope this makes sense 🙂

  • Hi @paulka

    There’s a plugin created by John called Reusable Field Group Field for ACF Pro. Please take a look at this thread to learn more about it: https://support.advancedcustomfields.com/forums/topic/reusable-field-groups/. I’m not sure if it will work with your situation, but I guess there’s no harm in trying it.

    Another method would be registering the fields by using the PHP code. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/register-fields-via-php/. With this method, you can create the required layouts as variables and then add them to the right place programmatically.

    I hope this makes sense 🙂

  • You could try something like this (if I understand your question correctly):
    https://github.com/Hube2/acf-reusable-field-group-field

  • Hi @voteforpedro

    We have a thread with the same request before. Here’s the link: https://support.advancedcustomfields.com/forums/topic/reusable-field-groups/.

    Unfortunately, it’s not possible in the current version of ACF yet. If you want, you can use the PHP code to make the field groups dynamically. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/register-fields-via-php/.

    I hope this helps 🙂

Viewing 25 results - 1 through 25 (of 70 total)