1

我有一个带有组合框的表单

  /*Business user type*/
            $Busertype = new Zend_Form_Element_Select("Busertype");
        $Busertype ->setLabel('Business user type')
          ->addFilter('StripTags') //StripTags : Enlève les caractères HTML
              ->setRequired(true)
               -> setMultiOptions(array(
                                '0' => '-Select your business type-',
                    '1' => 'Owner',
                                    '2' => 'Suplier',
                                    '3' => 'Representative',
                                    '4' => 'Shop'
        ));

我想检索组合框的内容,但是当我echo($busername)检索组合框的值时。那么如何显示组合框的内容

部分动作

  $form = new Application_Form_Inscriptionbu(); 
     $this->view->form = $form; //nous assignons le formulaire à la vue pour affichagee
     if ($this->getRequest()->isPost()) {  //Le formulaire est-il posté ?
     $formData = $this->getRequest()->getPost(); // récupère les infos des formulaires

     if ($form->isValid($formData)) { //Si le formulaire passe la validation
        $v = $form->getValues();
        $busername =$v['Busername'];
        echo($busername);
    }
4

1 回答 1

0

如果您想重新显示所选选项中的文本,您可以使用getMultiOption.

if ($form->isValid($formData)) { //Si le formulaire passe la validation
    $v         = $form->getValues();
    $busername = $v['Busername'];

    echo "You selected $busername which is called " . 
         $form->getElement('Busername')->getMultiOption($busername) . 
         '<br />';
}
于 2012-04-17T21:24:35.650 回答