Support

Account

Home Forums Front-end Issues radio button checked but no value

Solving

radio button checked but no value

  • Hi,
    I have 50 posts and a custom field radio button is checked for their corresponding choice in the posts. When I try and return the label in my template I get a blank value. If I go into the post and update the post the value then appears in my webpage. Is there a way to refresh all the radio button values to avoid having to open and update every post?
    Also if you switch a field from Checkbox to Radio buttons does it interfere with the values being displayed? Does switching from value to name to Both(array) cause these issues? Just wondering how sensitive the fields are in terms of data integrity.
    Thanks

  • ….I created the posts and the field values using a csv. Maybe it created the radio button values but not the labels?

  • You’re importer is probably not ACF aware and is probably not creating the needed ACF field key reference. If you’re importer has an ACF add on then you’ll need to use it. If not I would suggest http://www.wpallimport.com/, the pro version has an ACF add on that will do it correctly. Without the field key reference ACF does not know how to treat your field and that’s why nothing is returned.

    Radio fields store a single value, checkboxes store and array of values. You can’t swap out one for the other without adding checks to your template code to see if you’re getting an array or a single value.

    Returning value OR array also returns a single value for a radio field. In the case of a checkbox it returns an array of values. When you return both then a radio field will return an array containing both and a checkbox field will return an array of arrays (nested arrays). Again, you can’t just swap out one thing for the other without making code changes to deal with the values returned. For more information look at the documentation for each of these field types and how to deal with each of the return values.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘radio button checked but no value’ is closed to new replies.