2011-08-22 56 views
0

我有以下代码段, 在MyClass的,我已设置装饰变量,如何设置装饰器输入类型文件中的元素?

public $testDecorators = array(
    'ViewHelper', 
    'Errors', 
    array('Description', array('escape' => false, 'tag' => '', 'placement' => 'append')), 
    array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'itemR')), 
    array('Label', array('tag' => 'div', 'class' => 'itemL') 
    ), 
    array('HtmlTag', array('tag' => 'div', 'class' => 'itemcontent')) 
); 

在功能的CreateForm,

....

$cover_image = new Zend_Form_Element_File('cover_test', array(
     'label' => 'Cover Test:', 
     'value' => '', 
     'class' => 'test', 
     'tabindex' => '5', 
     'required' => false, 
     'filters' => array('StringTrim'), 
      'decorators' => $this->testDecorators, 
    )); 

....

当我使用此装饰,没有什么是显示在我的形式,如果评论说'decorators' => $this->testDecorators,形式未来罚款默认DD标签,请帮我

回答

4

file元素必须包含“文件”装饰,一般在地方的ViewHelper装饰。所以试试这个:

public $testDecorators = array(
    'File', 
    'Errors', 
    array('Description', array('escape' => false, 'tag' => '', 'placement' => 'append')), 
    array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'itemR')), 
    array('Label', array('tag' => 'div', 'class' => 'itemL'), 
    array('HtmlTag', array('tag' => 'div', 'class' => 'itemcontent')) 
); 
+0

谢谢非常有帮助 – mymotherland

1

你看什么$cover_image->getDecorators()节目吗?

而且,这是一个在中间正确:

array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'itemR')), 

岂不是:

array('HtmlTag', array('tag' => 'div', 'class' => 'itemR')), 

作为最后一个是什么?

+0

他的语法是正确的。您只能包含一个装饰用每个名称,数组语法允许别名他们。 –

+0

啊,是的,好的谢谢。 – ChrisA