Home >Backend Development >PHP Tutorial > zend_form 装饰器有关问题

zend_form 装饰器有关问题

WBOY
WBOYOriginal
2016-06-13 13:52:21851browse

zend_form 装饰器问题
表单里有个 项是单选框 ,包括4个选项,怎么让他们在一行显示啊 ,就是控制不好装饰器,初学zend framework,请帮忙指点下下

require_once ('Zend\Form.php');

class MessageForm extends Zend_Form {
  public function __construct($options = null){
  parent::__construct($options);
  $this->setName('message')->setAction('mangaer/message'); //设置表单名称  
  $m_type = new Zend_Form_Element_radio('m_type'); //添加表单元素
  $m_type->setLabel('主题分类')
->setMultiOptions(array('1'=>'我有疑问','2'=>'我的建议','3'=>'翻译服务', '4'=>'网站修改'))
  ->setRequired(true);
  $password = new Zend_Form_Element_Password('password'); //添加表单元素
  $password->setLabel('密码')
  ->setRequired(true)
  ->clearDecorators()
  ->addValidator('NotEmpty');  
   
  $submit = new Zend_Form_Element_Submit('submit'); //添加提交按钮
  $submit->setLabel('提交');
   
  $this->addElements(array($m_type,$password, $submit));//向表单中添加元素
   
   
  $this->clearDecorators();
  $this->addDecorator('FormElements')
  ->addDecorator('HtmlTag', array('tag' => '

    '))
      ->addDecorator('Form');
       
      $this->setElementDecorators(array(
      array('ViewHelper'),
      array('Errors'), 
      array('Label', array('separator'=>' ','tag'=>'label `')),
      array('HtmlTag', array('tag' => 'li', 'class'=>'element-group')),
      ));  

      // buttons do not need labels
      $submit->setDecorators(array(
      array('ViewHelper'),
      array('Description'),
      array('HtmlTag', array('tag' => 'li', 'class'=>'submit-group')),
      ));
       
     
      }
    }

    ?>

    ------解决方案--------------------
    这是因为zend framework生成了
  • 这个html标签,所以他才会显示在不同行,你将标签改掉就可以了
    array('HtmlTag', array('tag' => 'span', 'class'=>'element-group')),
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn