2013-03-24 4 views
5
function mymodule_search_form($form, &$form_state) { 

    $form..... define the form here 

    $form['submit'] = array(
    '#type' => 'submit', 
    '#value' => 'Search', 
); 

    return $form; 
} 

function mymodule_search_form_submit($form, &$form_state) { 

    //process the form and get result 
    $output = this is the result with a table of data. 
    //I want to display the result table here. 

//Now I can only use drupal message to display on top. 
drupal_set_message($output); 

    return; 
} 

したがって、基本的にデータベースから何かを検索するフォームが必要です。 一度送信するには、検索をクリックし、結果を取得します。drupal 7カスタムモジュールでフォームを送信した後にデータベースを照会して結果を表示

同じフォームページのフォームのすぐ下に結果を表示したいとします。 元のフォームページの別のページには移動しないでください。フォームがクリーンであることができる

/ファインで元の状態へリセット。

http://drupal.org/node/542646 このディスカッションは私が欲しいものですが、確かな結果や解決策はありません。

答えて

9

あなたは、例えば、再構築し、それが元の形の関数に存在する場合、それを表示するようにフォームを設定し、$form_stateに出力テーブルを隠しておくことができます

function mymodule_search_form($form, &$form_state) { 

    $form..... define the form here 

    if (!empty($form_state['results_table'])) { 
    $form['results_table'] = array('#markup' => $form_state['results_table']); 
    } 

    $form['submit'] = array(
    '#type' => 'submit', 
    '#value' => 'Search', 
); 

    return $form; 
} 

function mymodule_search_form_submit($form, &$form_state) { 
    $form_state['results_table'] = function_to_get_table(); 
    $form_state['rebuild'] = TRUE; 
} 
+0

ありがとうございました。テスト済み。うまくいった。 –

+0

ありがとうございました。助けました。とてもうまくいっていますが、Ajaxの送信ボタンではうまくいきませんでした。それでも問題は解決しました。 – Aniruddhsinh

関連する問題