2011-02-16 44 views

回答

2

有人已經回答你的問題Remove class=「form-item」 from Drupal forms
該函數給標題添加class ='title'。
但是對於class ='text',你應該使用theme_textfield(或theme_textarea)來擁有template.php
從./included/form.inc獲取代碼
但是,我建議按照自定義格式進行主題化,而不是所有表單元素。某處可能會引發樣式衝突等。當然,如果客戶不要求更改所有表單元素。在實際情況下,不需要更改默認元素。

9

對於第一種情況,添加類文本字段本身,使用#attributes屬性:

$form['foo'] = array(
    '#type' => 'textfield', 
    '#title' => t('Textbox title'), 
    '#attributes' => array(
    'class' => array('text'), // change to just 'text' for Drupal 6 
), 
); 

對於第二種情況 - 添加類的標籤,你的運氣與形式API。相反,你可以使用包裝類的字段和標籤的目標是:

.form-item-field-foo label { 
    /* CSS here */ 
} 
+1

請注意,在D7中,類的內容必須是數組,「'class'=> array('text'),」 – Berdir

+0

@Berdir你是對的; Drupal 6仍然在大腦中。固定。 – 2011-02-16 09:30:11

相關問題