[Zend_Form][1.12.0] Form instance in session

For programming and general questions on Zend Framework
Post Reply
Posts: 1
Joined: Mon Dec 03, 2012 8:48 pm

[Zend_Form][1.12.0] Form instance in session

Post by rclsilver » Mon Dec 03, 2012 8:54 pm


i've a Zend_Form instance with subforms stored in the user session.

The first time that the page is displayed, the form is generated, stored in session and displayed. At this moment, all is working fine.

The second time the page is displayed, the form instance is recovered from session and displayed. In this case, i've a problem with subforms.

For example, i've the following code :

Code: Select all

	public function testAction() {
		if($this->getParam('flush', 'false') === 'true' || !isset($_SESSION['form'])) {
			$_SESSION['form'] = new Zend_Form();

			$platform = new Zend_Form_SubForm();
			$_SESSION['form']->addSubForm($platform, 'platform');

			$appli = new Zend_Form_SubForm();
			$_SESSION['form']->addSubForm($appli, 'appli');

			$step = new Zend_Form_Element_Text('__step');

			$pfname = new Zend_Form_Element_Text('name');
			$pfname->setValue('platform name');
			$pfname->setLabel('platform name');

			$applinet = new Zend_Form_SubForm();
			$appli->addSubForm($applinet, 'net');

			$applinetaddr = new Zend_Form_Element_Text('addr');
			$applinetaddr->setLabel('Appli network address');

		$this->view->form = $_SESSION['form'];

		// Process request
		if($this->getRequest()->isPost()) {
			if($this->view->form->isValid($_POST)) {
				$this->view->data = $this->view->form->getValues();
When the form is displayed from the session ,the field appli[net][ipaddr] is renamed to appli[appli][net][ipaddr]... If i reload the page 3th time, the field name is now appli[appli][appli][net][ipaddr], etc... etc...

Anyone has an idean about the cause and/or the solution about this problem ?

Thank's a lot

Post Reply