Support

Account

Home Forums Bug Reports get_fields() does not return all values Reply To: get_fields() does not return all values

  • Hi @manu

    ACF saves two entries in the database, the value and the reference. The value will look like this in the database:

    field_name : field-value

    While the reference looks like this:

    _field_name : field_1234567890abc

    The reference is used by the get_field() function to find the right value for the right field name. That’s because you can have two fields with the same name, but not the same field key.

    When you execute this code:

    update_field('setCard_kontakt_bezirk', 'TestONE', $setCardId);

    ACF doesn’t know which field you want to update exactly (remember that you can have two fields with the same name), so it will only record the value entry.

    When you execute this code:

    update_field('field_57a2c771f3661', 'TestONE', $setCardId);

    ACF know which one you want to update, so it can create the reference key that is needed by the get_field() function.

    If the reference entry is recorded before (e.g. by saving the post from backend), it’s safe to use the update_field() function with the field name. But if it’s a new entry, you should use the field key instead.

    I hope this make sense 🙂