Support

Account

Home Forums Feature Requests Selecting fields to exclude from Clone field Reply To: Selecting fields to exclude from Clone field

  • There really isn’t a solution for this, at least not a reasonable one from a developer perspective using what exists in ACF. Anything path that I can think of to go down would, in the long run, be more time consuming than selecting individual fields to clone when creating the clone field, even when measured against how many time I would likely to need this functionality in the future.

    It would be much easier to set up different groups that would be cloned and separate out those fields that you only want to clone sometimes into their own groups.

    However, I will be honest, I avoid clone fields. It has been my experience that they end up requiring more time to code for than they save and also create confusion later on (in a year or so when you need to work on the site again.) I generally create new field groups even when they I’m using the same fields. Yes, this can cause extra work if you need to make changes to fields in the future, however, I’ve found that this happens infrequently enough that it does not really create that much work and I prepare for this ahead of time.

    This is a little off topic but, this is how I deal with duplicated fields.

    When I need to create a field that is the same as another field and I know that this field will always have the same settings in the future if I need to make changes, I keep notes.

    1. I open the field group with the fields I want to copy
    2. I make a note of the field key that I am going to copy, noted as the master field
    3. I note what field group, by ID and group key this master field is in
    4. I duplicate the field
    5. I move the field the other group I want it to appear in
    6. I open the other group and edit the field as necessary
    7. I note the “slave” field key and field group (key and ID)

    It is far easier to keep these notes when you’re doing the work instead trying to figure it out later. I also keep other notes as well in a readme.txt file. This is a file (or files) I create for every project I work on that needs more information than can be done using comments. I do this because most of my projects are long term and I know that in 6 months or a year or maybe more that I’m going to forget something important so I tell my future self all the stuff he may need to know so he doesn’t need to redo hours of research and testing to figure it out like I needed to do.

    Some time later I may need to change a field. When this happen I find the field key in question in my notes. Instead of editing the field I add an acf/load_field filter on the field key and all of the related field keys and make changes to the field in this filter. The next time I open the field group for editing all of the needed changes will be made. I may even go ahead and open/save each field group and then delete my filter, depending on if I’m in a hurry or not. I also make a not at this time that there is a filter in place for my future self.