• Resolved jc57

    (@jc57)


    Trying to pre-fill choices in a select field and having no luck. Have tried arrays, comma separated values, /r, /n, and /r/n separated values and nothing seems to work. I can pre-fill text fields, so I know the $args are being read, but can’t get the select to work. Any suggestions?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi! Sorry about the late reply.

    Using an array works for me while testing. I’ve set up a multiple select field and am passing an array of the values I wan’t selected to $args. Something like this:

     
    $args = array(
      'select' => array( 'value2', 'value3' ),
    );
    

    What does your code look like? ??

    Thread Starter jc57

    (@jc57)

    I was under the impression that profile values have to go in the “values” array and was trying something like this:

    $args = [
         'values' => ['adminSecName' => array("a", "b"), 'adding' => 'YES']
    ];

    where ‘adminSecName’ is the field name for the select box I’m working with.

    In your example it looks like you’ve specified the field name as it’s own key in the array. That didn’t seem to work for me either, but is it supposed to?

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Oh, of course. The values are supposed to go in the values part of args, my example was wrong.

    The way you have written it is the way I tested and it should work. Are you sure a and b are the actual values for the options? In ACF it’s possible to define both a value and a label for each of the options like this: “value : Label”. It’s the value that needs to be specified. ??

    Thread Starter jc57

    (@jc57)

    Yes, those are the values, but nothing shows up. Iv’ve tried it with the ‘value:label’ option as well and still don’t get anything. Any more ideas?

    Thread Starter jc57

    (@jc57)

    Thread Starter jc57

    (@jc57)

    Just forgot to mark as Resolved

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Pre-filling Select Fields’ is closed to new replies.