ZF-12044: Placeholder with no items but prefix set should render no content

Issue Type: Improvement Created: 2012-02-06T15:14:35.000+0000 Last Updated: 2013-02-13T15:25:55.000+0000 Status: Resolved Fix version(s): - 1.12.2 (25/Feb/13)

Reporter: Chris Jensen (cjensenius) Assignee: Frank Brückner (frosch) Tags: - Zend_View

  • View_Helper
  • state:need-feedback
  • zf-crteam-review

Related issues: Attachments:


If you have set a prefix/postfix to a placeholder, but do not assign any items, there is still output rendered when this placeholder is called. My desired behavior was to have no output if there were no items.

Altering the toString function in Zend_View_Helper_Placeholder_Container_Abstract by altering the call to copy the item array

<pre class="highlight">:

public function toString($indent = null)
    $indent = ($indent !== null)
            ? $this->getWhitespace($indent)
            : $this->getIndent();

    if(!$items  = $this->getArrayCopy()) { return ''; }
    $return = $indent
            . $this->getPrefix()
            . implode($this->getSeparator(), $items)
            . $this->getPostfix();
    $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return);
    return $return;



### Comments

Posted by Frank Brückner (frosch) on 2013-02-13T15:25:55.000+0000

Fixed on trunk (25254) and release-1.12 (25255)



Have you found an issue?

See the Overview section for more details.


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

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