zend_form 装饰器有关问题

原创
2016-06-13 13:52:21 593浏览

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')),
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。