Support

Account

Home Forums General Issues Does field->name have to be unique?

Solved

Does field->name have to be unique?

  • Also: What is the difference between ‘key’ and ‘name’ ?

  • That depends. The field name mush be unique on the WP object it is used for (post, term, user, options) You can have the same field name where they are not used on the same object.

    The field key is ACF’s internal way to refer to the field. The field key is always, and must always be unique.

  • What about subfields of Repeater fields?
    Does the key have to be unique for the whole database too?
    Does the name have to be unique inside the group or only within the subfields?

  • A group field is a repeater field with one row.

    A repeater fields top level field needs to be unique. Sub fields of a repeater need to be unique within each repeater. For example you can have 2 sub fields named “repeater_1” and “repeater_2” and both of these repeaters can have a sub field named “sub_field”.

    The field key is ACF’s internal reference to that specific field, no matter where that field is used. There must be a unique field key for every field created. Logically, if you have the same field key for 2 fields, as long as they are never used on the same WP object you would be okay, but I would not suggest it. It is too easy down the road to alter where the field is shown and then you could have a serious issue. ACF (internally) uses the field key, not the field name, to insure that it’s looking for the right field value.

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

The topic ‘Does field->name have to be unique?’ is closed to new replies.