Support

Account

Home Forums ACF PRO Select Field w/ PHP Generated Groups

Solved

Select Field w/ PHP Generated Groups

    • jwss76

    • July 10, 2014 at 3:22 am

    Small bug with the way select fields are being generated in the admin UI for fields and field groups created by php.

    I’m seeing instances where the ‘default_value’ option gets rolled into the ‘choices’ option.

    • Elliot

    • July 10, 2014 at 6:39 pm

    Hi @jwss76

    Thanks for the bug report, but I’m not sure I understand exactly where the issue occurs. Any chance of a screenshot?

    • jwss76

    • July 11, 2014 at 1:12 am

    Just looked in… I’m guessing it was a caching issue since it seems to have cleared up… If I notice it again I’ll post a screen shot.

    • jwss76

    • July 11, 2014 at 3:02 am

    Oops, Spoke to early on a solution, Here’s the screen shot:

    Display of select field default_option populating select field choices.

    Here’s the code that is creating the field:

    array (
    	'key' => 'field_538f375f143cb',
    	'label' => 'Show Related Posts',
    	'name' => 'tmv_related_posts',
    	'prefix' => '',
    	'type' => 'select',
    	'instructions' => '',
    	'required' => 0,
    	'conditional_logic' => 0,
    	'choices' => array (
    		'none' => 'Do not show related posts.',
    		'category' => 'Show posts from Category.',
    		'tmv_feature_type' => 'Show posts from Features.',
    		'tmv_topic' => 'Show posts from Topics.',
    		'post_tag' => 'Show posts from Tag.',
    		'tmv_today_type' => 'Show posts from Today.',
    		'cl_category' => 'Show posts from Classifieds.',
    		'cl_job_field' => 'Show posts from Job Type.',
    		'tmv_sport_tax' => 'Show posts from Sports.',
    		'tmv_sport_team_tax' => 'Show posts from Teams.',
    		'tmv_business_news_type' => 'Show posts from Business News.',
    		'tmv_business_field' => 'Show posts from field.',
    		'tmv_fr_lake' => 'Show posts from lake.',
    	),
    	'default_value' => array (
    		'none' => 'Do not show related posts.',
    	),
    	'allow_null' => 0,
    	'multiple' => 0,
    	'ui' => 0,
    	'ajax' => 0,
    	'placeholder' => '',
    	'disabled' => 0,
    	'readonly' => 0,
    	),
    
    • Elliot

    • July 11, 2014 at 10:19 am

    Hi @jwss76

    Thanks mate. I’ve added this issue for v5.0.1

    Cheers
    E

    • Elliot

    • July 16, 2014 at 11:31 am

    Hi @jwss76

    Thanks again for the bug repot.
    The issue is a miss-use of the default_value setting.
    Please change 'none' => 'Do not show related posts.', to 'none',.

    The issue here is that the default value is meant to be an array of values, not labels.

    Hope that makes sense.
    Changing the above will fix the issue!

    Cheers
    Elliot

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

You must be logged in to reply to this topic.

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.