2012-03-19 16 views
0

私は私のクラスに型ラジオの要素を持っているApplication_Form_LoginはZend_Formの取得値+ Zend Frameworkの

 $this->setMethod('post');  
     $this->setName("User type"); 
     $this->addElement('radio', 'User_type', array(
     'label' => 'User type:', 
     'multioptions' => array(
     1 => 'Owner', 
     2 => 'StandardUser', 
     3 => 'BusinessdUser',), 
      )); 

を拡張どのように私は、ラジオボタンの値を得ることができますか? あなたも

$form = new Application_Form_Login(); 
if ($this->getRequest()->isPost()) { 
    if ($form->isValid($this->getRequest()->getPost())) { 
     $value = $form->getValue('User_type'); 
     var_dump($value); 
    } 
} 
+0

あなたが送信ボタンを持っていますいくつかのタイプの正しい?あなたの行動は何に設定されていますか? – RockyFord

+0

「うまくいかない」ということを少し詳しく説明できますか?それは続くことではありません。もしあなたが 'var_dump($ _ POST);'? – vascowhite

答えて

0

を動作しません:

public function yourAction() { 
     $form = new SomeForm(); 
     if($this->getRequest->isPost()) { 
      $data = $this->getRequest->getPost(); 
      if($form->isValid($data)) { 
       $rate = $_POST['your_radio_button']; 
       // another code.. 
      } 
     } 
    } 
0

を試すことができます。また、試すことができ、私は私のコントローラでこのコードを試みたが、それは

$form = new Application_Form_Login(); 
    if ($this->_request->isPost()) { 
     if ($form->isValid($_POST)) { 
      $values = $form->getValues(); 
      var_dump($values['User_type']); 
     } 
    } 
関連する問題