2014-09-29 58 views
1

嗨有没有办法添加样式到表单元素,除了添加一个类?ZF2添加样式到元素

$this->add(array(
     'type' => 'Zend\Form\Element\Textarea', 
     'name' => 'notas', 
     'options' => array(
      'label' => 'Notas', 
      'label_attributes' => array(
       'class' => 'label-wrapped' 
      ), 
     ), 
    )); 

谢谢!

回答

1

这是这样的,但我还是不知道如何添加几种风格

$this->add(array(
    'type' => 'Zend\Form\Element\Textarea', 
    'name' => 'notas', 
    'attributes' => array(
     'style'=>'width:100px', 
    ), 
    'options' => array(
     'label' => 'Notas', 
     'label_attributes' => array(
      'class' => 'label-wrapped' 
     ), 
    ), 
)); 
+0

通过“几种风格的”你的意思是'风格“=>”宽度:100像素;身高:80px;''? – 2014-09-30 08:25:40

+0

@TimFountain我认为他的确如此。但我认为更好的方法是在视图中获取表单元素并在其中设置样式。 – Ronnie 2014-09-30 09:39:13

+6

我相信一个更好的方法是使用类,并避免内联-css :) – peterpeterson 2014-09-30 10:31:34