I recently discovered ACF and it’s revolitionised the way I use WP.
I’m having a small problem with setting up a new custom field.
I’m able to setup the field with no problem but it doesn’t save the value when a post is updated or published.
I’ve setup a test area here for you to take a look at:
Login username: acftest
It’s a fresh wordpress install with acf and my custom field installed as a plugin. The acf field group is linked to a standard post.
The custom field is a very basic radio button list with no options. The second field is a standard acf radio button field – which saves perfectly.
Here’s a list of things I have already tried:
1. Install the new custom field as a plugin.
2. Install the new custom field in the theme files and register with functions.php
3. Create a new “radion button” custom field using the standard acf radio button field code – just changing the appropriate name values.
4. Use new field with custom posts and standard wordpress posts.
5. Deactivated all other plugins.
6. Used standard wordpress theme.
7. WordPress versions used: 3.6.1 and 3.7
In all these cases I get the same result. Field shows up perfectly, just doesn’t save value. All other standard acf fields save perfectly.
When I used the standard acf radio buttons code as the template for the new custom field, the options section works perfectly to setup the field, but when you go to the post edit page none of the options are show on the form field – just the form field title shows. Nothing comes through in the html. Again, it seems that these field options are not being saved either.
Any assistance or insight would be greatly appreciated.
Thanks for a great plugin.
I have logged in anad taken a look.
Just to clarify.
This is not an issue with the ACF plugin. All ACF fields are saving values correctly.
The only issue here is with the ‘custom’ field type you have created / installed. It is not using the correct ‘name’ attribute to save the data.
Thanks for taking the time to look at my request. Really appreciate it.
Apologies for incorrectly filing this under ‘bugs’ when it’s my limited skills that are the problem 🙂
Can you please be more specific. I’ve tried to follow the tutorials and as much as I can and find as much in the forums as possible but I’m still not seeing it.
You are using a ‘custom’ field tpye (star rating).
This field type is using the wrong name attribute. That is why ACF is not saving it’s data.
Please review the docs on how to create a field type and study the field type template on github to learn how to set the correct name attribute
The issue is that you are using a custom ‘name’ attribute to POST the data. ACF requires the data to be posted with a very specific name attribute.
The code which causes the error is:
<li><input type="radio" name="rating" class="star" value="1">1</li>
Your name is rating. If you look at the source code for a normal ACF field, you will see that it is more like ‘fields[field_13434ydf]’
To make your field type compatibile, notice that the radio field uses $field[‘name’] for the name attribute! Not a custom name.
That should fix it.
Can you elaborate on what you mean by ‘doesn’t work’?
Yes, you are correct in stating that the name attribute is correct, but I’m not sure what is and isn’t working.
Perhaps you have another field with the same name which is preventing your field to save?
If you log in to that test space I setup you’ll see what I mean.
Login username: acftest
When I use the amended standard radio button code to create the new radio button field type, the options don’t pull through to the post edit form.
I was also unable to get my first code snippet to save when changing the name attribute as specified.
I’ve logged in and edited your plugin field. All I have done is a simple debugging technique called ‘print_r’ to show the contents of the variable available in the create_field function.
You can see the value of ‘choices’ and should be able to see why the loop does not work to create the radio inputs.
To ask me to fix your code is going beyond the free service I provide here, so this is as far as I can help you.
The issue is due to issues in your code, not ACF.
The topic ‘New custom fields doesn't save values’ 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!
© 2022 Advanced Custom Fields.