[ZF] set the value of a hidden field

Hello,

I’d like to set the value of a hidden form.

Consider the following snippets:

/forms/TestForm.php:

$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');
$this->addElements(array($id));

/controllers/TestController.php

$form = new Application_Form_TestForm();
       $form->id->setValue('VALUE VALUE VALUE');
       $this->view->form = $form;

The value is not set (or rather, it is set to ‘0’ in the HTML).

My point would be to retrieve a param from the queryString and use it as the hidden form value. But, I’m already trying to figure how to do it manually.

:slight_smile:

You define the ‘id’ field as an INT, and then want to put a string value (‘VALUE VALUE VALUE’) in it? Maybe that 0 is put in there because the validation performed by the class is forcing a zero in case of a non valid integer value?

And it was as simple as that… :slight_smile: