您好,我遇到了 zend 框架的问题。我想用 zend 制作一个多步骤表单,但 zend 不支持,所以我可以将 sub_form 保存在会话变量中并一一验证它们,然后在主表单的末尾获取所有 sub_form 以显示所有表格 ?
在此先感谢您的帮助 !
这是我的表单代码:
public function init()
{
/* Form Elements & Other Definitions Here ... */
$this->setAttrib("class", "form-horizontal well");
$name = $this->createElement('text', 'name', array(
"label" => $this->getTranslator()->translate('ADD_NAME'),
"description" => $this->getTranslator()->translate('ADD_EXAMPLE_NAME')
))->setRequired(true);
$trigram = $this->createElement('text', 'trigram', array(
"label" => $this->getTranslator()->translate('ADD_TRIGRAM'),
"description" => $this->getTranslator()->translate('ADD_EXAMPLE_TRIGRAM')
))->setRequired(true);
$environment = $this->createElement('select', 'environment', array(
"label" => $this->getTranslator()->translate('ADD_ENVIRONMENT')
))->setRequired(true);
$url_clientsite = $this->createElement('text', 'url_clientsite', array(
"label" => $this->getTranslator()->translate('ADD_URL_CLIENT'),
"description" => $this->getTranslator()->translate('ADD_EXAMPLE_URL')
))->setRequired(true);
$check_box = $this->createElement('multicheckbox', 'components', array(
"multiOptions" => array(
"mon" => " BDD Mona",
"sta" => " BDD Stats",
"log" => " BDD Logs",
"sal" => " Sali",
"agg" => " StatsAggregator",
"etl" => " ETL",
"jvs" => " JavaScript",
"adm" => " Admin"
)))->setRequired(true);
$step_1 = new Zend_Form_SubForm();
$step_1->addElements(array(
$name,
$trigram,
$environment,
$url_clientsite,
));
$this->addSubForm($step_1, 'step1');
$step_2 = new Zend_Form_SubForm();
$step_2->addElement($check_box);
$this->addSubForm($step_2, 'step2');
$step_3 = new Zend_Form_SubForm();
$step_3->addElements();
$this->addSubForm($step_3, 'step3');
}