Redirect 声明新实体ZF2后无法重定向

Redirect 声明新实体ZF2后无法重定向,redirect,zend-framework2,Redirect,Zend Framework2,我一直在遵循ZF2网站的代码 下面的代码用于工作。 当网站不工作时,它的输出是简单的。 其他控制器上的其他重定向正在工作 提前感谢=) 公共函数addAction(){ $form=新的CustomPerform(); $form->get('submit')->setValue('Add'); $request=$this->getRequest(); 如果($request->isPost()){ //$form->setInputFilter($customer->getInputFilt

我一直在遵循ZF2网站的代码

下面的代码用于工作。 当网站不工作时,它的输出是简单的。 其他控制器上的其他重定向正在工作

提前感谢=)

公共函数addAction(){
$form=新的CustomPerform();
$form->get('submit')->setValue('Add');
$request=$this->getRequest();
如果($request->isPost()){
//$form->setInputFilter($customer->getInputFilter());
$form->setData($request->getPost());
如果($form->isValid()){
//返回$this->redirect()->toRoute('customer/sub',array('controller'=>'customer');//redirect()->toRoute('customer/sub',array('controller'=>'customer'));//exchangeArray($form->getData());
$this->getCustomerTable()->saveCustomer($customer);
//重定向到相册列表
//返回$this->redirect()->toRoute('customer/sub',array('controller'=>'customer');
}
}
返回数组('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:



}
?>
名称空间客户\模型;
类客户{
public$customerID;
公共名称;
公共代码;
公共广播;
公费$postalCode;
国家公共财政;
公共城市;
国家公共财政;
公共$contactPersonName;
公共电子邮件;
公共电话;
公共传真;
公众地位;
公共美元信贷;
受保护的$inputFilter;//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']为空;
$this->postalCode=(isset($data['postalCode'])?$data['postalCode']:null;
$this->country=(isset($data['country'])?$data['country']:空;
$this->city=(isset($data['city'])?$data['city']:空;
$this->state=(isset($data['state'])?$data['state']:null;
$this->contactPersonName=(isset($data['contactPersonName'])?$data['contactPersonName']:null;
$this->contactEmail=(isset($data['contactEmail'])?$data['contactEmail']:空;
$this->contactTel=(isset($data['contactTel'])?$data['contactTel']为空;
$this->contactFax=(isset($data['contactFax'])?$data['contactFax']为空;
$this->status=(isset($data['status'])?$data['status']为空;
$this->credit=(isset($data['credit'])?$data['credit']为空;
}
//为此方法添加内容:
}
?>

听上去它好像在你的
$customer=new customer()
电话中死去。您是否有上面的use语句来注入客户/模型?

您的客户对象似乎没有实例化try take Dump of$Customer=new Customer();。如果您看到错误,那么我认为您需要检查您的模型,输出无错误,显示Customer中使用的所有值。object(Customer\Model\Customer)#370(15){[“customerID”]=>NULL[“name”]=>NULL[“code”]=>NULL[“address”]=>NULL[“postalCode”]=>NULL[“country”]=>NULL[“state”]=>NULL[“contactPersonName”]=>NULL[“contactEmail”=>NULL[“contactTel”]=>NULL[“contactFax”=>NULL[“contactFax”=>NULL[“status”=>NULL[“credition”]=>NULL[“credit”]=>NULL[“inputFilter”:受保护]=>NULL}您是否在IsValid()内转储了数据?是的,我在IsValid()内添加了数据。如果是如您所说的,则看起来完全正常,请尝试清除缓存,然后重试
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:



}
?>