manan
manan

Reputation: 234

how to use selected option of form select element in zend framework2?

I am using Zend\Form\View\Helper\FormSelect and I did not find the way to set selected value in select element.

$countryList = array_merge (array('empty_option' => 'Please choose...'),     
$this->common()->getCountryList() );
$country->setValueOptions($countryList);
$country->setValue(array('AT' => 'AUSTRIA'));
echo $this->formSelect($country);

Upvotes: 0

Views: 1492

Answers (1)

웃웃웃웃웃
웃웃웃웃웃

Reputation: 11984

$country->setValue('AT');
As above, you can use setValue() for making 'AT' as selected.

Upvotes: 1

Related Questions