zend_form 裝飾器有關問題

來源:互聯網
上載者:User
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')),

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.