Zend說。我構建了一個Zend_Form類。 我注意到,如果我傳遞字符串'0',我的表單元素的方法setDescription將它視爲NULL,我無法在元素描述中回顯其值。Zend將包含「Zero」的字符串傳遞給form-element說明
//this is how I set the element description in Myform class:
$element->setDescription('0');
我該如何避免這種情況?
感謝
盧卡
Zend說。我構建了一個Zend_Form類。 我注意到,如果我傳遞字符串'0',我的表單元素的方法setDescription將它視爲NULL,我無法在元素描述中回顯其值。Zend將包含「Zero」的字符串傳遞給form-element說明
//this is how I set the element description in Myform class:
$element->setDescription('0');
我該如何避免這種情況?
感謝
盧卡
根據http://php.net/manual/en/function.empty.php,php將'0'識別爲空。
描述裝飾器render()函數檢查描述是否爲空()。目前似乎沒有一種顯示'0'的方法。
此之前得到改變,我建議在http://framework.zend.com/issues
提交bug報告,最好的辦法就是創造它擴展了Zend的一個,並改變行爲您描述的裝飾。
這是我要做的事
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);
}
....
,然後例如
class Form_Contatto extends Gestionale_Form_Abstract_Form
...
$clienteid->setValue($this->_myParams['data']['id']);//
我會嘗試要麼是puttin g周圍的空白區域,或者禁用自動轉義並在範圍或其他標記中包裝0。
我的裝飾器設置:「array('Description',array('tag'=>'h2','placement'=>'append',」escape「=> false))」。你的建議沒有任何建議,感謝 – luca 2011-06-01 18:33:52
Ho riformulato la domanda =)ano io sono di Roma .. non ci conosciamo ?? – luca 2011-06-01 15:58:02