2011-10-13 10 views
0

私はDrupal 6のカスタムモジュールを開発しています。これは簡単なフォームを作成します。私の問題は、送信機能が呼び出されていない/処理されていることです!Myフォーム送信機能が動作しません

function listgroups_menu(){ 
    $items['user/%/groups-settings'] = array(
     'title' => 'Groups Settings', 
     'page callback' => 'listgroups_groups_list', 
     'page arguments' => array(1), 
     'access callback' => TRUE, 
     'type' => MENU_LOCAL_TASK, 
    ); 

    return $items; 
} 

function listgroups_groups_list ($uid){ 
    /* 
     * Couple lines here to access the DB & get the user's $groups. 
     */ 

    variable_set('listgroups_database_result', $groups); 
    $output = drupal_get_form('listgroups_settiongs_form'); 
    return $output; 
} 


/** 
* Form Builder 
*/ 
function listgroups_settiongs_form(){ 
    $groups = variable_get('database_result', array()); 
    //Building the form 
    $form['display_option'] = array(
     '#type' => 'checkbox', 
     '#title' => t('Show my group.'), 
    ); 
    $form['groups_selection'] = array(
     '#type' => 'radios', 
     '#title' => 'Please select your group', 
     '#options' => $groups, 
    ); 
    $form['submit'] = array(
     '#type' => 'submit', 
     '#value' => t('Save'), 
    ); 

    return system_settings_form($form); 
} 

/** 
* Submition 
*/ 
function listgroups_settiongs_form_submit($form, &$form_state){  
    echo "<pre>I'm heeeeeeeeeeeeeeeeeeeeeerr!!!</pre>"; 
    drupal_set_message('Your settings have been saved! YES!!!'); 
} 

さて、フォームは、DBのデータretrivalが完璧である&をレンダリング:ここに私のコードです。送信ボタンをクリックすると、何も得られません。ページだけが更新されます&メッセージは表示されません!!

なぜでしょうか?

答えて

1

使用

return $form; 

代わりの

return system_settings_form($form); 

、問題はあなたがsystem_setting_formを使用する場合、それは一般的に使用されているシステム設定ページとして動作を開始したも

function xyz_form_submit($form, &$form_state){  
    //echo "<pre>I'm heeeeeeeeeeeeeeeeeeeeeerr!!!</pre>"; 
    drupal_set_message('<pre>I\'m heeeeeeeeeeeeeeeeeeeeeerr!!!</pre>Your settings have been saved! YES!!!'); 
} 

いくつかの情報をデータベースに保存する。したがって、通常のフォームにする場合は$ formのみを返す必要があります。

+0

を参照してください、それを割り当てる含めます!ありがとう:) – Yasmen

関連する問題