ZF-2829: Populate nulls out Image src


When I populate a form my image src attrib is being set to null

Code below:

$image = new Zend_Form_Element_Image('submitImage');
    ->setAttrib('class', 'button');


if ($this->_request->isPost()) {
    if ($form->isValid($this->_request->getPost())) {
    } else { 



Scheduling for RC2

Fixed in trunk and release branch.

Images now behave pretty differently:

  • use setImage() to set the image (or use the 'image' configuration key); this will populate the src for the input
  • use setImageValue() to set the value the image will submit (or use the 'imageValue' configuration key)
  • isChecked() tells you when the value set in the element matches the imageValue (as long as the imageValeu is not null itself)
  • the label is now rendered as the alt attribute of the input
  • If no image is set via setImage(), any value present will be used for the input src

First i wanted to offer you a very big thank you for all your help and work on the Image Element.

Secondly i would like to point out that the setImageValue() method is not setting the value attrib as expected. It is always being passed to the view helper as NULL and thus returning false for isChecked().

Example: Sets value attrib but isChecked is returned false


Value attrib is not set and isChecked is returned false



Ken, I cannot reproduce what you're saying. I have the following code:

$image = new Zend_Form_Element_Image('foo');
      ->setView(new Zend_View())
echo $image;
echo "\n\n" . var_export($image->isChecked(), true);

Expected and actual results are:


You are correct. Issue has been resolved. I forgot to attach revision # that i was using when this was happening. All is working as expected currently.

Thanks Ken