setDefaults?

From: Date: Wed, 04 Jan 2006 20:16:20 +0000
Subject: setDefaults?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22438@lists.php.net to get a copy of this message
The variable $comArray looks like this (according to a var_dump): array(5) { [""]=> string(35) "— Select the Builder. —" [25]=> string(23) "AW Properties West, LLC" [32]=> string(17) "Chivalry Software" [26]=> string(14) "McMillin Homes" [248]=> string(10) "Shea Homes" } The following line correctly creates a select menu: $form->addElement('select', $name, $role . ':', $comArray); This exists within a foreach loop, so $name has values like "BuilderID" and $role has values like "Builder". The line following is my understanding of the use of setDefaults(): $form->setDefaults(array($name => $projRec[$name][0])); which evaluates to: $form->setDefaults(array('BuilderID' => '248')); But this doesn't work. $projRec[$name][0] (according to a var_dump) returns the correct ID for the given role, so when $name is "BuilderID", that snippet correctly returns "248", but even when I manually insert "248" in place of the expression, there's still no default selected. The first item in the array ("— Select the Builder —") is selected instead. Where am I going wrong? Thanks Chuck Ross

« previous php.pear.general (#22438) next »