Home › Forums › Bug Reports › issues related to field key references › Reply To: issues related to field key references
Since this is one of the few topics about field key references, I’ll post what fixed it for me.
If you have problems that seems to point to the wrong reference key being retrieved, make sure you don’t have a filed name duplicated SOMEWHERE ELSE.
I know you probably triple-checked the fields failing to save the data to the right key, but that was what was mixing up my field values.
I kept double and triple checking the field values and keys of the fields of the issue… I even fed the update_field function with the right keys, rather than field names, and it still failed, but I never thought to check OTHER fields from other subfields in other layouts (flexible content sub_fields).
I really thought “if using the same name is so terrible, it would be plain prohibited, validated and auto-corrected if necessary”.
When the keys are retrieved from the DB, and one is overwritten with the other in the array being generated, the indexes of the returned field keys don’t match the total fields and I assume that’s why the value for one field ends up in another, completely unrelated. It probably affects fields that were created after the one with the duplicated name.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.