Dynamic Dropdown only display first letter of label
-
I copied the filter from the post directly into my functions and manually created an array to test. The result is that only the first letter of the label is displayed, even though the options array is properly created. Embed for image seems to not be wokring. Here is the link to the image: https://ibb.co/6Pj3XKZ
{ "1": "one", "2": "two", "3": "three" }
add_filter( 'cf7sg_custom_dynamic_select','student_name_dynamic_options',10,3); /** * Filter dropdown options for dynamic drodpwn list of taxonomy terms. * @param Array $options the option to filter. * @param WPCF7_FormTag $tag field tag object. * @param string $cf7_key the form unique key. * @return Array $options return either an array of <option value>=><option label> pairs or 2 arrays, one for values and another for attributes. */ function student_name_dynamic_options($options, $tag, $cf7_key){ if('ipad-incident-report'!==$cf7_key || 'student_name' !== $tag->name){ return $options; } //these are the label users will see when the dropdown opens. //you can group your options if need be. Let's assume you have an array of arrays of data to display in groups. //$data = ... //fetch your data, either from the database or some other source. $data = array( '1' => 'one', '2' => 'two', '3' => 'three' ); foreach($data as $value=>$label){ $options[$value]=$label; //if you are displaying more complex select2 fields, or imagegrid for dynamic checkbox, then add extra parameters into a 2nd array of attributes, //$options['values'][$value]=$label; //$options['attributes'][$values]= array('data-thumbnail'=>'<image url>'); } return $options; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Dynamic Dropdown only display first letter of label’ is closed to new replies.