0

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);
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
manan
  • 234
  • 2
  • 9

1 Answers1

1
$country->setValue('AT');
As above, you can use setValue() for making 'AT' as selected.
웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91