how to setup a default value in select object?
i'am creating a select object with drupal form api, and i want ti setup a defautl value from the array of options $net = drupal_map_assoc(array('Dial-up', 'Cable/dsl', 'Lan')); $form['meet_net'] = array( '#type' => 'select', '#options' => $net, '#title' => t('Network'), '#default_value' => $net['Lan'], ); i can do this with that variant, but i need to user numeric values from the array, by example '#default_value' => $net[2], for save data in database?? how can i do that them?? -- ---------------------- Aldo Martinez Selleras Administrador del Nodo CITMATEL GND Camaguey Tel: 32-291661 E-mail: aldo@caonao.cu Linux User #364356
I think what you want is $net = array(0 => 'Dial-up', 1 => 'Cable/dsl', 2 => 'Lan')); $form['meet_net'] = array( '#type' => 'select', '#options' => $net, '#title' => t('Network'), '#default_value' => $existing_net_value, ); You will need to initialize $existing_net_value either from the existing value in the database or else some default value. As show valid values are 0, 1 and 2
participants (2)
-
Aldo Martinez Selleras -
Steve Ringwood