Zend Mutipage フォーム チュートリアルhttp://framework.zend.com/manual/en/zend.form.advanced.htmlコードに示されている例を取得することができましたが、検証で問題が発生しました。
フォームの最初の部分は正常に読み込まれますが、フォームの 2 番目の部分で [保存して続行] ボタンをクリックすると、検証エラー メッセージが表示されます。(ユーザーがサブフォームの 2 番目の部分を送信したときにのみ検証エラーがポップアップするため、これは正しくありません)。
Zendフレームワークのチュートリアルページに示されている例のようです
if (!$temp->formIsValid())
{
$form = $this->getNextSubForm();
$this->view->form = $this->getForm()->prepareSubForm($form);
return $this->render('prepaid-funeral-plan');
}
フォーム全体が有効かどうかを確認しますが、ユーザーがデータを送信する前に、サブフォームの 2 番目の部分で検証エラーがポップアップするという問題が発生します。
フォーム processAction() の完全なコードは次のとおりです。
public function processAction()
{
if (!$form = $this->getCurrentSubForm()) {
// if there's no form data goto the beginning form stage
return $this->_forward('prepaid-funeral-plan');
}
if (!$this->subFormIsValid($form,$this->getRequest()->getPost()))
{
$this->view->form = $this->getForm()->prepareSubForm($form);
return $this->render('prepaid-funeral-plan');
}
if (!$this->formIsValid())
{
$form = $this->getNextSubForm();
$this->view->form = $this->getForm()->prepareSubForm($form);
return $this->render('prepaid-funeral-plan');
}
// Valid form!
// Render information in a verification page
$this->view->info = $this->getSessionNamespace();
$this->render('verification');
//Clear the session data!
Zend_Session::namespaceUnset($this->_namespace);
}
よろしくお願いします!