I am trying to set the 'selected' tag in the array of months to the current month. I know I have to add the 'selected' tag to the array item, but where does it go? w3schools shows it as this:
<option value="fiat" selected>Fiat</option>
For the life of me I cannot see where to put 'selected'
$form['month'] = array( '#type' => 'select', '#title' => ('Select Month or The Full Year'), '#options' => array( '01' => t('January'), '02' => t('February'), '03' => t('March'), '04' => t('April'), '05' => t('May'), '06' => t('June'), '07' => t('July'), '08' => t('August'), '09' => t('September'), '10' => t('October'), '11' => t('November'), '12' => t('December'), '13' => t('The Full Year'), ), );
I have looked at the form functions in the API but cannot find anything to help.
Thanks in advance.
Hey @themetman,
If you are actually looking for a way to set the default value, then simply do this:
If you are looking to add other attributes (such as classes/ID etc.) to
'#type' => 'select'
form elements, then read on...