Home › Forums › General Issues › Issue with radio field type not saving selection & entering new choice instead › Reply To: Issue with radio field type not saving selection & entering new choice instead
The problem is that when you use the “other” choice to allow custom entries what happens is that ACF compares the submitted values against the existing values. At this point the existing value is an unescaped html value while the submitted value has had the html escaped. The values do not match so ACF thinks it is a new value and then proceeds to save this new escaped value.
This can be overcome by adding an acf/update_value filter (https://www.advancedcustomfields.com/resources/acf-update_value/) with a priority of < 10 so that your filter can run before the built in ACF filter. In this filter you can then correct the submitted value to be correct HTML before ACF makes its comparison. However, you should be very careful doing so because this will allow users to submit HTML which could allow XSS attacks on your site.
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.