Home Forums General Issues How to identify clone field key to use with $_POST['acf']


How to identify clone field key to use with $_POST['acf']

  • Hi,

    I have an inactive field group (month_year) made of 2 fields month and year, which is then cloned for usage to another field group (with the field name month) … with name prefixes, so I have an unambiguous field_name for both fields, and can get either with get_field().

    I am using both values to set a hidden field, and I get the logic that makes that possible.

    However, my challenge is in checking whether either value has changed in $_POST[‘acf’]. Every example I have seen for using $_POST[‘acf’] suggests that you search for field keys and not field names.

    Problem is that within the ACF UI, the parent field that contains the 2-field clone has a field key displayed, but the contained cloned fields don’t have field keys displayed.

    So, is it valid to test for a change in the value of either via the parent field key?

    if isset($_POST[‘acf’][‘field_5fb1d6bb0dfdd’])

    in the above, field_5fb1d6bc40dfdd is the field key for the parent field (month) … not the cloned fields: month_month and month_year.

  • Open a page to edit, use inspect element on the field and look at the field keys in the field name to see what acf with use in $_POST[‘acf’]

  • Thanks a million, @hube2 … I was able to figure this out in the end.

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

You must be logged in to reply to this topic.