[development] how to setup a default value in select object?

Steve Ringwood nevets at mailbag.com
Thu Dec 18 17:30:24 UTC 2008


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

 




More information about the development mailing list