Forms Zend:如何从Select元素表单中获取值?

Forms Zend:如何从Select元素表单中获取值?,forms,zend-framework,select,element,Forms,Zend Framework,Select,Element,嗨,我是zend的新手,这个问题可能很可笑,但我很难从以下方面获得价值: $country = new Zend_Form_Element_Select('_country'); $country->setLabel('Country:'); $country->addMultiOptions(array('0'=>'United States',

嗨,我是zend的新手,这个问题可能很可笑,但我很难从以下方面获得价值:

            $country = new Zend_Form_Element_Select('_country');
            $country->setLabel('Country:');
            $country->addMultiOptions(array('0'=>'United States',
                                            '1'=>'Bolivia',
                                            '2'=>'Argentina',
                                            '3'=>'Afganistan'));
            $country->setRequired(true);
但我不确定如何获取这些值,我在控制器上尝试了以下方法:

if ($this->_request->getPost()) {
        $formData = $this->_request->getPost();
        $form = new App_Form_CustomerForm();

        if ($form->isValid($formData)) {
            $customer = $customerDao->getById($id);             
                            $customer->setCountry($formData[0]['_country']);                
            $customerDao->save($customer);
            $this->_helper->redirector('index');

            return;

我想只使用html代码来进行选择,但我想知道如何获取这些值。

您可以使用
getValue()
方法从zend元素获取值

代码应该是

if ($form->isValid($formData)) {
    $customer = $customerDao->getById($id);             
    $customer->setCountry($form->getValue('_country'));                
    $customerDao->save($customer);
    $this->_helper->redirector('index');

    return;
    }