Skip to main content
deleted 564 characters in body
Source Link
Ashok KS
  • 391
  • 4
  • 17

The belowYour code works for meshould be work,

$banks = array(14=>"bank one", 22=>"bank two);

I then want to construct a simple select form element generally use key value as default value, this WILL NOT work:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#default_value' => 22  // will NOT work!
);

But this works:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#value' => 22  // works!
);

The problem is isif it not working make the string as keys and use it as default value cannot be changed !!!

This was on Drupal 6.15 for more here

The below code works for me,

$banks = array(14=>"bank one", 22=>"bank two);

I then want to construct a simple select form element, this WILL NOT work:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#default_value' => 22  // will NOT work!
);

But this works:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#value' => 22  // works!
);

The problem is is value cannot be changed !!!

This was on Drupal 6.15 for more here

Your code should be work, generally use key value as default value, if it not working make the string as keys and use it as default value.

added 51 characters in body
Source Link
Ashok KS
  • 391
  • 4
  • 17

The below code works for me,

$banks = array(14=>"bank one", 22=>"bank two);

I then want to construct a simple select form element, this WILL NOT work:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#default_value' => 22  // will NOT work!
);

But this works:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#value' => 22  // works!
);

The problem is is value cannot be changed !!!

This was on Drupal 6.15 for more here

The below code works for me,

$banks = array(14=>"bank one", 22=>"bank two);

I then want to construct a simple select form element, this WILL NOT work:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#default_value' => 22  // will NOT work!
);

But this works:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#value' => 22  // works!
);

This was on Drupal 6.15 for more here

The below code works for me,

$banks = array(14=>"bank one", 22=>"bank two);

I then want to construct a simple select form element, this WILL NOT work:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#default_value' => 22  // will NOT work!
);

But this works:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#value' => 22  // works!
);

The problem is is value cannot be changed !!!

This was on Drupal 6.15 for more here

Source Link
Ashok KS
  • 391
  • 4
  • 17

The below code works for me,

$banks = array(14=>"bank one", 22=>"bank two);

I then want to construct a simple select form element, this WILL NOT work:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#default_value' => 22  // will NOT work!
);

But this works:

$form['drop'] = array(
#id' => "bank_drop",
'#type' => 'select',
'#title' => 'test',
'#options' => $banks,
'#value' => 22  // works!
);

This was on Drupal 6.15 for more here