Wrong value for radio and select fields
-
Please fix custom_field function that’s applied via woocommerce_form_field_<field_type> filter.
You’re injecting labels into radio and select values.
case 'radio': $field = ''; if (!empty($args['options'])) { $field .= ' <span class="woocommerce-radio-wrapper" ' . implode(' ', $custom_attributes) . '>'; foreach ($args['options'] as $option_key => $option_text) { $field .= '<input type="radio" class="input-checkbox" value="' . esc_attr($option_text) . '" name="' . esc_attr($key) . '" id="' . esc_attr($key) . '_' . esc_attr($option_key) . '"' . checked($value, $option_text, false) . ' />'; $field .= '<label for="' . esc_attr($key) . '_' . esc_attr($option_key) . '" class="checkbox ' . implode(' ', $args['label_class']) . '">' . $option_text . '</label><br>'; } $field .= ' </span>'; } break; case 'select': $field = ''; if (!empty($args['options'])) { $field .= '<select name="' . esc_attr($key) . '" id="' . esc_attr($args['id']) . '" class="select ' . esc_attr(implode(' ', $args['input_class'])) . '" ' . implode(' ', $custom_attributes) . ' data-placeholder="' . esc_attr($args['placeholder']) . '">'; if (!empty($args['placeholder'])) { $field .= '<option value="" disabled="disabled" selected="selected">' . esc_attr($args['placeholder']) . '</option>'; } foreach ($args['options'] as $option_key => $option_text) { $field .= '<option value="' . esc_attr($option_text) . '" ' . selected($value, $option_text, false) . '>' . esc_attr($option_text) . '</option>'; } $field .= '</select>'; } break;
It’s supposed to be $option_key not $option_text inside value=””
Breaks all other plugins that rely on value.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Wrong value for radio and select fields’ is closed to new replies.