代码之家  ›  专栏  ›  技术社区  ›  Andrew

zend framework:如何删除zend_form_element_文件上的dtdd decorator?

  •  2
  • Andrew  · 技术社区  · 14 年前

    我已经尝试了我能想到的每一件事,我不知道如何只显示 ViewHelper 装饰师 Zend_Form_Element_File .

    $UserPhoto = new Zend_Form_Element_File('UserPhoto');
    $UserPhoto->setDestination(TMP_DIR);
    $UserPhoto->addValidator('Count', false, 1);
    $UserPhoto->addValidator('Size', false, 10240000); // 10 mb max
    $this->addElement($UserPhoto);
    

    在我的视图脚本中:

    echo $this->form->UserPhoto
    

    产生

    <dt>label</dt>
    <dd>input element</dd>
    

    这就是我想要的:

    input element
    
    2 回复  |  直到 14 年前
        1
  •  2
  •   Ololo    14 年前

    最短的形式是:

    $UserPhoto->setDecorators(array('File'))
    
        2
  •  2
  •   Andrew    14 年前

    这是我唯一能让它工作的方法:

    $this->addElement($UserPhoto, 'UserPhoto');
    $this->UserPhoto->removeDecorator('label');
    $this->UserPhoto->removeDecorator('htmlTag'); //DtDd
    
    推荐文章