Was wondering if there was an established best practice for select field options. My situation is I built out all the options for the selections in the field settings and made selections for fields on an existing page. I set it up as described (red : Red) expecting that as long as I kept the label the same I would be able to update the actual content without having to reselect it on the page upon every change. From what I can see if I make any change at all it resets that particular field on the page. Is this how it is supposed to work? Are we meant to have all select fields absolutely sorted and set in stone before making selections on the page? Seems a bit restrictive and unwieldy (would love to be able to have an option like ‘Build webpages : Web Design’ that I could later change to ‘Build webpages and mobile apps : Web Design’ without having all the currently made selections on pages reset as the label
Web Design remained unchanged), but if thats the method would love to confirm asap so I don’t waste any effort moving forward.
the “value” of the field is what is used.
red : Red
the value is “red” the label is “Red”. As long as the value part stays the same then it does not matter what you change the label to or what order this value appears in. If you change the value part, then the value “red” becomes an invalid value and when you edit the page again this value will not be shown in the selections, and since it will not appear in the selections it cannot be selected even if that is the value for the field on that page.
Thanks, this is indeed how I understand it. This makes sense and I understand it is easier said then done, but it would be very useful to be able to have the reverse functionality – the ability to have the field “hold on to” the label but allow the value to be adjusted. Just to give you my test case usage, I am building a
Employment History list, so I put together a list of universal
Job Duties that I would apply to different positions which I could then select for each position from a dropdown. Now I have all of them selected on the page, but want to reword the actual value that gets outputted on my site. So now it looks like I will need to set the wording of the value in stone and then go back and select them all again. This means if I ever need to update them its a complete redo, which is why I was hoping the field could lock onto the
Label (only displayed to admin so not so worried about the wording) which would allow the value (displayed to visitors, so thats what really could use flexibility) to be updated without blowing up my existing page selections. Of course it may just be that the
select field isn’t the appropriate solution for such a case (and I am very appreciative of any alternate suggestions) but it seems anytime the value gets changed it blows up any previous selections (makes total sense if a bit less flexible than I would hope for in a perfect world). Thank you!
I would leave the values alone, reword the label and then display the label instead of the value. ACF5 now has a setting to return the labels instead of the values when using get_field(). Even if you don’t use this setting it’s possible to get the labels foe each value of the field.
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!
© 2022 Advanced Custom Fields.