Select field options missing values
-
Hi!
On line 131 of class-wc-checkout-field-editor.php, the option for the default WooCommerce select is overwritten, but the value attribute is missing:
$options .= '<option '. selected( $value, $option_key, false ) . '>' . esc_attr( $option_text ) .'</option>';
Should be this instead:
$options .= '<option '. selected( $value, $option_key, false ) . ' value="'.$option_key.'">' . esc_attr( $option_text ) .'</option>';
And on line 141, the select name is appended with []:
$field .= '<select name="' . esc_attr( $key ) . '[]" id="' . esc_attr( $key ) . '" class="checkout_chosen_select select wc-enhanced-select ' . $class . '">
You can test with this code and see that the option value are missing:
woocommerce_form_field( 'test', array( 'type' => 'select', 'options' => array( '1' => '1', '2' => '2' ), ), '2' );
- The topic ‘Select field options missing values’ is closed to new replies.