Issues

ZF-5937: disableTranslator option in Zend_Form_Element_Multi makes the options disappear

Issue Type: Bug Created: 2009-03-04T06:40:22.000+0000 Last Updated: 2009-06-18T11:38:45.000+0000 Status: Resolved Fix version(s): - 1.8.4 (23/Jun/09)

Reporter: Edouard Cunibil (duael) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: - ZF-5195

Attachments: - Multi.php

Description

When the disableTranslator flag is true on a multi options element, new options added with the addMultiOption method are never really added to the options stack.

Here is the patch I made. I have not signed the CLA for the moment but I give you this patch without any restriction.

/**
 * Translate an option
 *
 * @param  string $option
 * @param  string $value
 * @return bool
 */
protected function _translateOption($option, $value)
{
    if ($this->translatorIsDisabled()) {
        return false;
    }

    if (!isset($this->_translated[$option]) && !empty($value)) {
        $trValue = $this->_translateValue($value);
        if ($trValue === $value) {
            return false;
        }
        $this->options[$option] = $trValue;
        $this->_translated[$option] = true;
        return true;
    }

    return false;
}

Comments

Posted by Edouard Cunibil (duael) on 2009-03-04T06:47:24.000+0000

Corrected file

Posted by Johan B.W. de Vries (jbwdevries) on 2009-03-20T12:09:37.000+0000

Just to clarify: _translateOption returns TRUE when the translator is disabled, while it should return FALSE.

All that needs changing is:

<pre class="highlight">
        if ($this->translatorIsDisabled()) {
            return true;
        }

into

<pre class="highlight">
        if ($this->translatorIsDisabled()) {
            return false;
        }

Posted by Mike Willbanks (digitalstruct) on 2009-05-23T20:34:07.000+0000

Created patch for issue and provided phpunit test.

Posted by Matthew Weier O'Phinney (matthew) on 2009-06-18T11:38:41.000+0000

Patch from Mike Willbanks applied in trunk and 1.8 release branch -- thanks!

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