2014-09-29 55 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