ZF-11380: Zend_Form_Decorator_HtmlTag::_htmlAttribs doesn't accept class methods as attribute callback

Issue Type: Bug Created: 2011-05-14T13:08:07.000+0000 Last Updated: 2011-08-08T15:43:09.000+0000 Status: Open Fix version(s): Reporter: Pawel Tomulik (ptomulik) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

Related issues: Attachments:


It seems, that Zend_Form_Decorator_HtmlTag::_htmlAttribs() method doesn't accept class methods as attribute callback. For example the following code will not cause later rendering of "class" attribute as it could be expected:

<pre class="highlight">
class Some_Class {
  public function someMethod($decorator) {
    return 'someClass';
$obj = new Some_Class();
       'class' => array('callback' => array($obj,'someMethod')))

The solution may be to slightly patch the "Zend/Form/Decorator/HtmlTag" with the following patch:

<pre class="highlight">
--- Zend/Form/Decorator/HtmlTag.php 2011-03-01 18:25:24.000000000 +0100
+++ Zend-Patched/Form/Decorator/HtmlTag.php 2011-05-14 14:49:29.000000000 +0200
@@ -86,7 +86,7 @@
             if (is_array($val)) {
                 if (array_key_exists('callback', $val)
                     && is_callable($val['callback'])) {
-                    $val = $val['callback']($this);
+                    $val = call_user_func($val['callback'],$this);
                 } else {
                     $val = implode(' ', $val);

The patch makes _htmlAttribs() to use "call_user_func" to call user-provided callback.


No comments to display

Have you found an issue?

See the Overview section for more details.


© 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.