Quantcast
Viewing all articles
Browse latest Browse all 297377

numeric optionkeys in select forms don't work as expected, values get replaced

$form['myselect'] = array(
'#title' => 'My Select',
'#key_type' => 'associative',
'#type' => 'select',
'#options' => array(
'NORMALKEY' => 'Normal Key',
'307' => '307', // numeric key...
'OTHERKEY' => 'Other Key',
'20' => '20', // another numeric key..
),
);

produces a form-select like:

<select id="edit-myselect" class="form-select" name="myselect">
<option value="NORMALKEY">Normal Key</option>
<option value="0">307</option>
<option value="OTHERKEY">Other Key</option>
<option value="1">20</option>
</select>

instead of:

<select id="edit-myselect" class="form-select" name="myselect">
<option value="NORMALKEY">Normal Key</option>
<option value="307">307</option>
<option value="OTHERKEY">Other Key</option>
<option value="20">20</option>
</select>

Viewing all articles
Browse latest Browse all 297377

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>