私が行ったいくつかの調査に基づいて、質問を再構成しますか?
$_SESSION['client_error']、$_SESSION['state_error'] などのように、多くのエラーを個別に保存する必要があります。Zend のドキュメントによると、エラーごとにこのように保存する必要がありますか?
$client_error = new Zend_Session_Namespace(''client_error);
$state_error = new Zend_Session_Namespace('state_erro'); and so on?
これはコントローラーの私のコードです。$this->view->state_error_message=$state_error; として保存しています。
ビューで $this->state_error をエコーした後、設定を解除します。
さて、私が試したいくつかのことは次のとおりです。policyInfoActionのコントローラーで:
session_start();
$error_message = new Zend_Session_Namespace('error_message');
$error_message="TEST";
$this->view->error_message=$error_message;
$this->_redirect('/pdp/client-info/');
client-info のビュー:
session_start();
<?php echo $this->error_message; ?>
これは何も返しません。
これは私の更新されたコードです:
public function clientInfoAction()
{
$errors = new Zend_Session_Namespace('errors');
// get the error arrays
$client_errors = (isset($errors->client_error)) ? $errors->client_error : array();
$state_errors = (isset($errors->state_error)) ? $errors->state_error : array();
unset($errors->client_error, $errors->state_error); // delete from the session
// assign the values to the view
$this->view->client_errors = $client_errors;
$this->view->state_errors = $state_errors;
}
public function policyInfoAction()
{
if (count($arrErrors) > 0)
{
// The error array had something in it. There was an error.
$strError="";
foreach ($arrErrors as $error)
{
$strError="";
$errors->client_error = array();
$errors->state_error = array();
foreach ($arrErrors as $error)
{
$strError .= $error;
// to add errors to each type:
$errors->client_error['client_error'] = $strError;
$errors->client_error[] = $strError;
$this->_redirect('/pdp/client-info/');
}
}
}
$this->client_errors をエコーすると、「Array」が表示されます