ZF2 ウェブサイトのコードに従っています。
次のコードは以前は機能していました。うまくいかなかったときのウェブサイトの出力は明白です。他のコントローラーの他のリダイレクトが機能しています。
よろしくお願いします=)
public function addAction() {
$form = new CustomerForm();
$form->get('submit')->setValue('Add');
$request = $this->getRequest();
if ($request->isPost()) {
//$form->setInputFilter($customer->getInputFilter());
$form->setData($request->getPost());
if ($form->isValid()) {
//return $this->redirect()->toRoute('customer/sub', array('controller' => 'customer')); //<-- This line works
$customer = new Customer();
return $this->redirect()->toRoute('customer/sub', array('controller' => 'customer')); //<-- This line does not working
$customer->exchangeArray($form->getData());
$this->getCustomerTable()->saveCustomer($customer);
// Redirect to list of albums
//return $this->redirect()->toRoute('customer/sub', array('controller' => 'customer'));
}
}
return array('form' => $form);
}
Customer.php
namespace Customer\Model;
class Customer {
public $customerID;
public $name;
public $code;
public $address;
public $postalCode;
public $country;
public $city;
public $state;
public $contactPersonName;
public $contactEmail;
public $contactTel;
public $contactFax;
public $status;
public $credit;
protected $inputFilter; // <-- Add this variable
public function exchangeArray($data) {
$this->customerID = (isset($data['customerID'])) ? $data['customerID'] : null;
$this->name = (isset($data['name'])) ? $data['name'] : null;
$this->code = (isset($data['code'])) ? $data['code'] : null;
$this->address = (isset($data['address'])) ? $data['address'] : null;
$this->postalCode = (isset($data['postalCode'])) ? $data['postalCode'] : null;
$this->country = (isset($data['country'])) ? $data['country'] : null;
$this->city = (isset($data['city'])) ? $data['city'] : null;
$this->state = (isset($data['state'])) ? $data['state'] : null;
$this->contactPersonName = (isset($data['contactPersonName'])) ? $data['contactPersonName'] : null;
$this->contactEmail = (isset($data['contactEmail'])) ? $data['contactEmail'] : null;
$this->contactTel = (isset($data['contactTel'])) ? $data['contactTel'] : null;
$this->contactFax = (isset($data['contactFax'])) ? $data['contactFax'] : null;
$this->status = (isset($data['status'])) ? $data['status'] : null;
$this->credit = (isset($data['credit'])) ? $data['credit'] : null;
}
// Add content to this method:
}
?>