Issues

ZF-2829: Populate nulls out Image src

Issue Type: Bug Created: 2008-03-07T13:12:41.000+0000 Last Updated: 2008-03-21T17:17:26.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Ken Crane (kcrane377) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: Attachments:

Description

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

Code below:

<pre class="highlight">
$image = new Zend_Form_Element_Image('submitImage');
$image->setLabel('')
    ->setValue('test.gif')
    ->setAttrib('class', 'button');
$form->addElement($image);

Outputs:

<pre class="highlight">
if ($this->_request->isPost()) {
    if ($form->isValid($this->_request->getPost())) {
    } else { 
        $form->populate($this->_request->getPost());
    }
}

Outputs:

Comments

Posted by Matthew Weier O'Phinney (matthew) on 2008-03-07T14:45:09.000+0000

Scheduling for RC2

Posted by Matthew Weier O'Phinney (matthew) on 2008-03-07T16:28:39.000+0000

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

Posted by Ken Crane (kcrane377) on 2008-03-08T11:56:58.000+0000

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

<pre class="highlight">
->setImage('test.gif')
->setValue('someValue')

Value attrib is not set and isChecked is returned false

<pre class="highlight">
->setImage('test.gif')
->setImageValue('someValue')

Ken

Posted by Matthew Weier O'Phinney (matthew) on 2008-03-17T13:39:36.000+0000

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

<pre class="highlight">
$image = new Zend_Form_Element_Image('foo');
$image->setImage('/images/test.gif')
      ->setImageValue('foobar')
      ->setView(new Zend_View())
      ->setValue('foobar');
echo $image;
echo "\n\n" . var_export($image->isChecked(), true);

Expected and actual results are:

<pre class="highlight">




true

Posted by Ken Crane (kcrane377) on 2008-03-17T14:54:47.000+0000

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts