2017-04-17 58 views
0

創建一個新的模塊,並在它的形式,但是當我提交表單只有一個字段被打印其值的所有其他沒有得到他們的價值觀:ZF2表不顯示所有字段的值時提交

有超過10個字段,但只有電子郵件字段正在打印其值,所有其他都是空的。

這就是我在我的表格:

public function __construct($name = null) 
{ 
    // we want to ignore the name passed 
    parent::__construct('company'); 

    $this->add(array(
     'name' => 'id', 
     'type' => 'Hidden', 
    )); 


    $this->add(array(
     'name' => 'email', 
     'type' => 'Text', 
     'options' => array(
      //'label' => 'Strasse', 
      // 'placeholder' => 'Email' 

     ), 
     'attributes' => array(
     'placeholder' => 'Email', 
     ), 

    )); 
    $this->add(array(
     'name' => 'firstname', 
     'type' => 'Text', 
     'options' => array(
      //'label' => 'Strasse', 
      // 'placeholder' => 'Email' 

     ), 
     'attributes' => array(
     'placeholder' => 'Vorname', 
     ), 
    )); 

    $this->add(array(
     'name' => 'submit', 
     'type' => 'Submit', 
     'attributes' => array(
      'value' => 'Go', 
      'id' => 'submitbutton', 
     ), 
    )); 
} 

我在我的模式獲取值如下,但它沒有顯示所有的值。

public function saveCompany(Company $company) 
{ 
    $data = array(
     'firstname'  => $company->firstname, 
     'email'  => $company->email, 

    ); 
    echo '<pre>'; print_r($data); 
     exit; 

我是什麼錯誤donig你能指出,讓我知道,如果你需要進一步的代碼在這裏顯示。

Out Put Image

回答

0

我把它固定的領域是在exchageArray功能錯過了我更新了它,現在工作的罰款:

public function exchangeArray($data) 
{ 
    $this->id    = (!empty($data['id'])) ? $data['id'] : null; 
    $this->vorname   = (!empty($data['vorname'])) ? $data['vorname'] : null; 
    $this->nachname  = (!empty($data['nachname'])) ? $data['nachname'] : null; 
    $this->email   = (!empty($data['email'])) ? $data['email'] : null; 
    $this->volstangir  = (!empty($data['volstangir'])) ? $data['volstangir'] : null; 
    $this->strasse   = (!empty($data['strasse'])) ? $data['strasse'] : null; 
    $this->hausnummer  = (!empty($data['hausnummer'])) ? $data['hausnummer'] : null; 
    $this->plz    = (!empty($data['plz'])) ? $data['plz'] : null; 
    $this->ort    = (!empty($data['ort'])) ? $data['ort'] : null; 
    $this->telenummer  = (!empty($data['telenummer'])) ? $data['telenummer'] : null; 

}