2013-12-21 2 views
0

데이터베이스에 데이터를 삽입하려고합니다. 그리드에 표시하지만 오류가 발생합니다. 멤버 함수를 호출하면 비 객체에 Value()가 반환됩니다.31 행의 /var/www/docs/Project.com/public/application/controllers/ClientController.php에있는 객체가 아닌 객체의 getValue() 함수를 호출하십시오.

여기 내 컨트롤러 코드입니다.

public function addAction() 
{ 
$form = new Application_Form_user(); 
$form->submit->setlabel('add'); 
$this->view->form = $form; 

if($this->getRequest()->isPost()) 
{ 

    $formData= $this->getRequest()->getPost(); 

    if($form->isvalid($formData)) 

     $client= new Application_Model_DbTable_Client(); 

    $firstname = $formData->getValue('firstname'); 
      $lastname = $formData->getValue('lastname'); 
      $email = $formData->getValue('email'); 

     echo"<pre>"; 
      print_r($fisrtname);die; 
      $client->addClient($firstname,$lastname,$email); 

      $this->_helper->redirector('index'); 
    } 

} 

내 모델 코드.

public function addClient($firstname,$lastname,$email) 
{ 

    $data=array('fisrtname'=>$firstname, 
       'lastname'=>$lastname, 
       'email'=>$email); 
    $this->insert($data); 
} 

내 사용자 양식 코드입니다.

class Application_Form_user extends Zend_Form 
{ 
    public function init() 
{ 
    $id = new Zend_Form_Element_Hidden('id'); 
    $id->addFilter('Int'); 

    $firstname = new Zend_Form_Element_Text('firstname'); 
    $firstname->setlabel('firstname'); 
    $firstname->setRequired('true'); 


    $lastname = new Zend_Form_Element_Text('lastname'); 
    $lastname->setlabel('lastname'); 
    $lastname->setRequired('true'); 

    $email = new Zend_Form_Element_Text('email'); 
    $email->setlabel('email'); 
    $email->setRequired('true'); 

    $submit = new Zend_Form_Element_Submit('submit'); 
    $submit->setlabel('submit'); 
    $submit->setRequired('true'); 


    $this->addElements(array($id, $firstname, $lastname, $email, $submit)); 
}      

}

답변

0

내가 거기 오히려 fisrtname보다 FIRSTNAME해야한다 인덱스 이름에 맞춤법 실수를이

$formData = $this->getRequest()->getPost(); 
if($form->isvalid($formData)) 
    $client = new Application_Model_DbTable_Client(); 
$firstname = $formData['firstname']; 
$lastname = $formData['lastname']; 
$email  = $formData['email']; 
+0

답장을 보내 주셔서 감사합니다.하지만 추가 버튼을 클릭하면 데이터가 데이터베이스 양식에 입력되지 않습니다. – Tuhin

0

죄송보십시오.

관련 문제