开发者

Zend passing string containing "Zero" to form-element Description

Zend talk. I built a Zend_Form class. I noticed that if I pass the string '0' the method setDescription of开发者_C百科 my form-element will consider it as NULL and I can't get to echo out its value in the element description.

//this is how I set the element description in Myform class:
$element->setDescription('0');

How can I avoid that?

Thanks

Luca


According to http://php.net/manual/en/function.empty.php, php recognizes '0' as empty.

The Description decorator render() function checks to see if the description is empty(). There doesn't currently appear to be a way to display just a '0'.

I'd suggest filing a bug report at http://framework.zend.com/issues

Until that gets changed, your best bet is to create your own Description decorator which extends the Zend one and changes the behavior.


I'd try either putting some whitespace around it, or disabling the auto escaping and wrapping the 0 in a span or another tag.


this is how i do it

abstract class Gestionale_Form_Abstract_Form extends Zend_Form
{
    protected $_myParams;//params per customizzare il form in base all'action edit/new

    public function __construct($options = null, $myParams = null)
    {
        $this->_myParams = $myParams;
        parent::__construct($options);
    }

....

and then for example

class Form_Contatto extends Gestionale_Form_Abstract_Form
...
    $clienteid->setValue($this->_myParams['data']['id']);//
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜