It happen something like that to me. Updating saves the data that was read fine from the DB to the post editor, but is not found in the front end until re-saved.
The problem was my fields being created by code and there was a duplicate field key (duplicated on purpose – I assumed the source of the meta-custom field in the DB would be shared for both ACF fields).
The duplicate field key doesn’t have to be THE ONE of the problem. Just by having one duplicate field key in the same group, it can ruin other fields (most probably the ones created later, not the ones before, since the hole in the array generated by one element using an existing key instead of another one affects the NEXT items in the array, not matching the original index… or so).
I created a script for that.
Just put the script in your functions.php file.
“Both adding and removing rows in the middle of the pack” doesn’t necessarily mean to follow the instructions I mentioned above.
You have to delete the one RIGHT after the one you just added. (i.e. the one you clicked the + button on, to add the new row)
Yes, I mean the little number at the top-left of each row.
Here’s the screen capture.
ACF pro 5.2.7
No error in console.
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.
Ohhh… I DID have this problem time ago. I hope I remember this the day those websites get ACF updated! This and/or setting up my own key names when programmatically declaring the field groups for several websites will give me a headache soon 🙁
Thanks everyone for the long detailed posts 🙂
This gives me an insight of the issues I’m having right now.
This and “allow me to recycle the fields” kind of feature requests could be fixed by adding a new input field to the field creation process to select another field as the source of the ref _key. That would make to ignore all the settings for that field, so it would be faster to create them. Not optimal, but it will provide a field-reusage system 🙂
I’ll take a look at the code to see if I can inject the new custom field everywhere without breaking anything and we might have a solution to mine and this kind of issues 🙂
My tone is civil. The worst thing I said is “you are wrong”, which is my opinion, based in the answers you give me. Please don’t take it personal, as none of my words insinuated that.
For the ammount of words… sorry, but I need them to be clear when i think I’m not being understood. Maybe your developers could consider not to dismiss a request with a rushed up answer? When an answer doesn’t add up, I bring it up.
The repeater fields doesn’t work to make field layouts… Maybe I was confused because YOU DID call them “layouts”!
The repeater field leaves a hole in table mode when the fields are conditionally hidden (of course, because there’s a table header needing to match)
The word “layout” DOES REFER to the ARRANGEMENT of things, NOT to the types and data or the data itself. I don’t feel bad by thinking they were meant to work as layouts.
Can you think any other way to prevent the browser to become unresponsive with 10 rows of 8 wysiwyg fields each? (I’m not even counting the conditionally hidden ones!)
I do need the wysiwyg fields, to let the user to enter bullet points because of the nesting levels…
Unless you add some kind of YAML field? where users can quickly enter data with leading dashes or tabs, to define lists, arrays…
Later we, programmers, could convert each nesting level into title, content, even complex layouts, from plain text. Without the need for multiple wysiwyg fields, or field layouts.
CSS has many ways to select an element. I’m sure I could find the right selector for you to accomplish that… If I only knew what you are showing in the image. I have no idea what that is or what it is for. Is that the field builder? or the created field with some repeater?
I don’t think that would be too hard to accomplish hacking the plugin’s code. Finding where the code is rendered and adding a class with the field’s type is one of the easiest things to do. If you give me more info I could give it a shot.
I want to add new ROWS to an EMPTY flexible content field, based (e.g. exploded w/JS) from ANOTHER acf field (or the wp editor).
For future visitors: I already made my importer processing the fields with a function hooked to acf/save_post wordpress hook.
It parses a whole powerpoint presentation into slides, including base64 images, something I recommend you to add to your plugin, like “image elevator” 🙂
It seems that “update_field” is all I needed. I thought there would be some sort of “add row”… but since the whole thing is a acf field…
The only problem I found is the last ticket I submitted. One sub-field doesn’t makes it to the DB but it doesn’t come out to the editor. Please take a look at it. I can send you my code, but really, I checked the field BEFORE update_field, and it was ok, as well as the data found in the DB. But no show.
About image-elevator: One could just install it, and paste the images in a wysiwyg editor, but as it happened to me, my wordpress post ended up with two wysiwyg editors for each row, (apparently one many more than it was designed for) which made the browser twice as slow.
And I had to modify their plugin to work from the back end, since currently theirs only works with ajax from the post editor. Anyway, allowing to “paste” an image I think it’d be a great addition 🙂
I tried to duplicate one, but then I can’t change the layout type.
When there’s no field around of the same type, my only option is “add page”.
Collapsing sounds like a good idea. Just put a “collapse all” button, and re-arranging should be few screen lengths easier 🙂
But you can leave the change in the (whatever you call your latest not-for-release version) so I can download it 🙂
If you think this is possible (using a single wysiwyg and creating a snapshot of the rest until needed) I’d do it myself.
I have no idea how, but I managed to import a whole powerpoint with base64 images and everything saved to the media library in one week 🙂
Just send me a few lines of critical points where you think I could encounter a challenge, and I’ll try it.
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!
© 2021 Advanced Custom Fields. Subscribe