ZF2中的Bootstrap内联表单布局

时间:2015-10-30 10:27:29

标签: zend-framework2 bootstrapping

我的视图文件index.phtml中有以下代码。

<div class="form-group">
    <?php echo $this->formRow($form->get('daterange'));?>
</div>
<div class="form-group">
    <?php echo $this->formRow($form->get('itemInterval')); ?>
</div>
<div class="form-group">
    <?php echo $this->formRow($form->get('submit')); ?>
</div>

我想要一个内联表单。我想要的是在一条线上拥有所有控件。您可以在图片中看到我现在的形式:enter image description here

以下是来自IncidentsForm.php的代码:

     class IncidentsForm extends Form
 {
     public function __construct($name = null)
     {
         // we want to ignore the name passed
         parent::__construct('incidents');
         $this->setAttribute('method', 'post');
         $this->setAttribute('class', 'form-inline');

        $this->add(array(
            'type' => 'text',
            'name' => 'daterange',
            'options' => array(
                'label' => 'Start Time'
            ),
            'attributes' => array(
                'id' => 'daterange',
                'class' => 'form-control'
            ),
        ));

        $this->add(array(
            'type' => 'select',
            'name' => 'itemInterval',
            'options' => array(
                'label' => 'Item interval',
                'options' => array( 3 => 3, 5 => 5 )
            ),
            'attributes' => array(
                'id' => 'itemInterval',
                'class' => 'form-control'
             ),
        ));

        $this->add(array(
            'name' => 'submit',
            'type' => 'Submit',
            'attributes' => array(
                'value' => 'Filter',
                'id' => 'submitbutton',
                'class' => 'form-control'
            ),
        ));
     }
 }

0 个答案:

没有答案