scribu / wp-scb-framework

Utilities for speeding up WordPress plugin and theme development
https://github.com/scribu/wp-scb-framework/wiki
220 stars 55 forks source link

More than two <options>s are selected #26

Closed scribu closed 11 years ago

scribu commented 11 years ago

Minimal code to reproduce:

echo scbForms::input( array(
    'name' => 'whatever',
    'type' => 'select',
    'choices' => array(
        '1/2',
        '1',
        '1 1/3',
    ),
    'selected' => '1 1/3'
) );

Result:

<label><select name="whatever">
<option value="1/2">1/2</option>
<option value="1" selected="selected">1</option>
<option value="1 1/3" selected="selected">1 1/3</option>
</select></label>

A user reported this bug against P2P:

http://wordpress.org/support/topic/issue-with-selects-on-the-post-editor

scribu commented 11 years ago

Somehow, '1' gets casted to an integer, and in PHP, 1 == '1 1/3' is true, because why not?