Home › Forums › General Issues › Dynamic Select from Options Textarea – Not saving selected value on post edit › Reply To: Dynamic Select from Options Textarea – Not saving selected value on post edit
Hi elliot,
Here is the code for the option:
if( function_exists('acf_add_options_sub_page') ) { acf_add_options_sub_page(array( 'title' => 'Settings', 'parent' => 'edit.php?post_type=bne_team_schedule', 'capability' => 'edit_posts' )); } function bne_team_schedule_team_names_load_field( $field ) { $field['choices'] = array(); $choices = get_field('bne_team_schedule_team_names_options', 'option'); $choices = explode("\n", $choices); if( is_array($choices) ) { foreach( $choices as $choice ) { $field['choices'][$choice] = $choice; } } // Important: return the field return $field; } add_filter('acf/load_field/name=bne_team_schedule_home_team_name', 'bne_team_schedule_team_names_load_field');
Attached is screenshot of the option field which is subpage of the CPT and a screen of what is outputted into the select field within ACF. Like I said, the database seems to store the correct choice but when you update the post the select field, visually, resets to the first choice in the list.
Using ACF v4.3.0 and Options v1.2.0
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.