I have same problem when creating a brand new Repeater Field. First “Save” isn’t really saved it only save the Custom Field. I need to recreate the Repeater Field a second time to be saved.
Not a big deal since it’s saving on the second try but can be a pain for those who haven’t notice this bug.
I quickly looked under the hood and found a few things about my issue:
– The ‘save_post’ hook isn’t firing when I update a Page. Not sure exactly why…documentation is slim even though this is a common problem…but perhaps we should hook the
acf_admin_field_group::save_post() method to ‘pre_post_update’ instead?
– The ‘field_group’ nonce can fail when there are multiple field groups. This writes multiple ‘_acfnonce’ hidden inputs to the page’s form. The last input value stomps the other nonce values (which don’t appear in the POST params). Perhaps the _acfnonce value should be keyed to each particular field group?
I would be happy to contribute code to fix these issues if you give the thumbs up, Eliot.
Hope that helps.
Glad that worked for you. I’m pretty sure the issue I’m seeing is due to bugs in ACF PRO 5.0.8. I double checked the errors I described above, and would only add that the duplicate nonces are created because
acf_admin_field_group::edit_form_after_title() uses the same key as the nonce in
acf_input::acf_form_data(). This appears to be by design, because they both use the same nonce validation function,
acf_verify_nonce(). This makes me think that the field-group nonce was not properly implemented, and should either be removed or rewritten to use a different nonce (which would affect the nonce verification as well).
Anyway, since this isn’t up on Github yet, here is a patch [http://pastie.org/9611813] for those experiencing these issues. I removed the field-group nonce entirely until the dust settles. I also hook onto ‘pre_post_update’, then remove this action once it’s executed (to avoid a loop).
UPDATE: Read below, don’t apply this patch.
The fix I posted above was on the right track to hook into ‘pre_post_update’, but just went about it in the wrong way. I got a little spun around tackled the wrong save_post() method.
So, there is one simple change to fix this problem on my installation, so please ignore my patchfile above. Here is a better patch which fixes the problem of subfields not saving on our installation.
In short, hook
acf_form_post::save_post() onto ‘pre_post_update’ instead of ‘save_post’.
The topic ‘Sub fields not saving’ is closed to new replies.
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!