This is the combo box for month field :

$form['issue_date']['month'] = array(
'#type' => 'select',
'#title' => t('Month * '),
'#options'=>$month, //$month=array of int 1 to 12
);

i want the current month to get selected by default.
Just like we do use "option selected" abc "/option" in html
i tried :
'#selected'=>date("m"); //did not work

What is its equivalent attribute in drupal?

Thank u
v

Comments

mokargas’s picture

Here's the reference:
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/5

I believe you need to use #default_value, not #selected

depace’s picture

'#default_value'=>12

vaishnavig’s picture

i got the solution , it is :

$current_month=date("m");
$form['issue_date']['month'] = array(
:
:
'#default_value'=>variable_get('month',$month[$current_month]),//month=name of combo
);

anyways ,thank u 2 both of u