Experiencing the same issue with the details posted to the list:

http://www.nabble.com/Zend_Form-Populate-and-Element_Image-Issue-td15622
171s16154.html

The image is my submit button and since the src attribute is set by 
->setValue when I populate the form the image value|src is nulled out
thus no image|submit button.

No responses though...
Ken


-----Original Message-----
From: Jeffrey Sambells [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 26, 2008 7:18 PM
To: Zend Framework - General
Subject: [fw-general] Zend_Form how to prevent null values

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