2012-02-08 8 views
0

drupalのフィールド属性を変更する方法を教えてもらえますか?7 hello_testという名前のhello_testをhelloとして作成しました。今度はラベルを変更する必要があります私のテーマのtemplate.phpファイルの属性を設定してください。誰でも助けてもらえますかdrupalのフィールドのid属性を変更して設定する7

答えて

0

私は数日前に同じ問題に直面しました。 onblurとonfocusというテキストフィールド属性を設定すると、うまくいきませんでした。正確には、動作していましたが、profile2モジュールのフォーム変更によって上書きされたため、表示できませんでした。

あなたのフォームは、apiがprofile2モジュールのフォームalter apiの前に読み込まれると思います。だから上書きされます。私は別の名前空間にカスタムフォームの変更を作成することで私の問題を解決しました。

function yourCustomModuleName_form_profile2_edit_testing_candidate_form_alter(&$form, &$form_state) { 

    $form['profile_testing_candidate']["field_candidate_name"] = array(
     "#title" => "Candidate Name", 
     "#type" => "textfield", 
     "#required" => TRUE, 
     "#description" => t(""), 
     '#default_value' => 'Given Name', 
     '#attributes' => array (
      'onblur' => "if (this.value == '') {this.value = 'Given Name'}", 
      'onfocus' => "if (this.value == 'Given Name') {this.value = ''}", 
     ), 
    ); 

    $form['profile_testing_candidate']["field_candidate_family_name"] = array(
     "#title" => "", 
     "#type" => "textfield", 
     "#required" => FALSE, 
     "#description" => t(""), 
     '#default_value' => 'Family Name', 
     '#attributes' => array (
       'onblur' => "if (this.value == '') {this.value = 'Family Name'}", 
       'onfocus' => "if (this.value == 'Family Name') {this.value = ''}", 
     ), 
    ); 
} 
関連する問題