Hi All,

I've been integrating Zend_Form and have a bit of a problem I'm trying to resolve.

Let's say I have a form such as this:

$form = new Zend_Form();

$title = new Zend_Form_Element_Text( 'title' );

$hidden = new Zend_Form_Element_Hidden('secret')
$hidden->setValue('whatever');

$form->addElements( array(
    $title, $hidden
) );


Now in my actual case this is an extended form object and the addition is in the constructor but this example is simpler. My problem is that I want to specify the value of the hidden field when I set up the form and not have it blown away. Later on in the script, I want to populate the remaining fields from a database or whatever but the hidden field isn't in that dataset and gets overwritten with null.

For example, If I do this:

$data = array(
        'title' => 'my title'
);

$form->populate( $data );

the hidden field is then nulled.

Is there a way to create a form element that will retain the default value if not included when you populate the form?

Reply via email to