Dynamic Dropdown Custom Options
-
Hi. I’ve been trying to implement dynamic dropdown custom options with the filter you’ve provided:
add_filter( ‘cf7sg_dynamic_dropdown_custom_options’,’dynamic_select_000_dynamic_options’,10,3);.So far, I haven’t been able to make it work.
Can you help me?
Here is how I did it:
I’ve tried it in two different ways:
First method: Setup Data through hard-code
$data = array( "group_label" => array( "group_optionss" => array( "label1" => "value1", "label2" => "value2", "label3" => "value3", ) ) ); foreach($data as $group_label=>$group_opts){ $options .= '<optgroup label="'.$group_label.'">'; foreach($group_opts as $label=>$value){ $options .= '<option value="'.$value.'">'.$label.'</option>'; } $options .= '</optgroup>'; } return $options;Second method: Use options directly
$options .= '<optgroup label="group_label">'; $options .= '<option value="value1">label1</option>'; $options .= '<option value="value2">label2</option>'; $options .= '<option value="value3">label3</option>'; $options .= '</optgroup>'; return $options;Honestly, I thought it was gonna work on the second method. Can you help me implement your filter code for dynamic dropdown custom options?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Dynamic Dropdown Custom Options’ is closed to new replies.