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')),
-