[fw-core] Zend_Form_Element_Select default value?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[fw-core] Zend_Form_Element_Select default value?

Brad Waite-2
How, pray tell, does one set the default value/selected option in a
select element?

Given:

$select = new Zend_Form_Element_Select('qty');
$select->addMultiOptions(array('one' => 'one', 'two' => 'two', 'three'
=> 'three'));

Neither

$select->setValue('two');

or

$select->setValue(array('two));

work. Nothing jumps out in the source, either.

Thanks for the help.

-bmw

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: [fw-core] Zend_Form_Element_Select default value?

Wil Moore III
Brad Waite-2 wrote
$select = new Zend_Form_Element_Select('qty');
Try:

$select = new Zend_Form_Element_Select('qty', 'two');
or
$select = new Zend_Form_Element_Select('qty', array('two'));
--
Wil Moore III

Best Practices for Working with Open-Source Developers
http://www.faqs.org/docs/artu/ch19s02.html

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost