Home › Forums › Backend Issues (wp-admin) › grouped and none-grouped fields
Hey guys,
Yesterday I had an issue with the way fields are named when grouped or not.
It might be something that should have been obvious but to me it was a first running into this issue.
I am currently in a transition stage from the free Advanced Custom Fields to the Pro version.
And though we are not actively going through all the fields to change them where necessary, we do change them so they are grouped and neatly layed out on the page editor page.
Now here is the issue.
I made a field of the type group called “hero”
This group was meant to replace a field set also called “hero”
In the old group I had multiple fields of which I will name 2 below (to make the issue clearer).
Fieldset: Hero – old
-> hero_title (type: text)
-> hero_subtitle (type: text)
So then I made a new fieldset like this.
Fieldset: Hero – new
-> hero (type: group)
-> title (type: text)
-> subtitle (type: text)
Again this is just a part of the full fieldsets but you get the point.
Now the thing that happend was this.
When I added the new fieldset, it was added to the top of the fieldset order on the page editor screen.
When I tried to save the new title and subtitle, they wouldn’t save.
I tried to debug the php and found that wordpress indeed failed to save the values I entered.
After much trail and error and a not so good night of sleep…. I was looking in the documentation and the database for the fields in question.
That’s when I noticed that in the database ACF knows what fields are there and what fieldset and or group they belong to.
But when it is saved, the field inside the “hero” group is saved as “hero_title” and the same for the subtitle. Which means that it is also saved as “hero_subtitle”
With this knowlede I tried changing the order of the fieldsets in the page editor screen.
This worked and now the old fields are overwritten.
Is this a bug or a thing that was always there and it was just coincidence that I stumbed on this now?
Cheers.
Hey guys,
Yesterday I had an issue with the way fields are named when grouped or not.
It might be something that should have been obvious but to me it was a first running into this issue.
I am currently in a transition stage from the free Advanced Custom Fields to the Pro version.
And though we are not actively going through all the fields to change them where necessary, we do change them so they are grouped and neatly layed out on the page editor page.
Now here is the issue.
I made a field of the type group called “hero”
This group was meant to replace a field set also called “hero”
In the old group I had multiple fields of which I will name 2 below (to make the issue clearer).
Fieldset: Hero – old
-> hero_title (type: text)
-> hero_subtitle (type: text)
So then I made a new fieldset like this.
Fieldset: Hero – new
-> hero (type: group)
-> title (type: text)
-> subtitle (type: text)
Again this is just a part of the full fieldsets but you get the point.
Now the thing that happend was this.
When I added the new fieldset, it was added to the top of the fieldset order on the page editor screen.
When I tried to save the new title and subtitle, they wouldn’t save.
I tried to debug the php and found that wordpress indeed failed to save the values I entered.
After much trail and error and a not so good night of sleep…. I was looking in the documentation and the database for the fields in question.
That’s when I noticed that in the database ACF knows what fields are there and what fieldset and or group they belong to.
But when it is saved, the field inside the “hero” group is saved as “hero_title” and the same for the subtitle. Which means that it is also saved as “hero_subtitle”
With this knowlede I tried changing the order of the fieldsets in the page editor screen.
This worked and now the old fields are overwritten.
Is this a bug or a thing that was always there and it was just coincidence that I stumbed on this now?
Cheers.
You must be logged in to reply to this topic.
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!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN
— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.