0

I created on custom module to generate a form with this code

function report_page_form_form($form, &$form_state) {
    $meberArr = array();
    $form['field_member_org']=array(
        '#type'=>'select',
        '#options'=> $meberArr,
    );
    $form['field_start_date'] = array(
      '#date_format' => 'Y-m-d',
      '#type' => 'date_popup',
      '#weight'=>0,
    );
    $form['field_end_date'] = array(
      '#date_format' => 'Y-m-d',
      '#type' => 'date_popup',
      '#weight'=>0,
    );
// Provide a submit button.
          $form['submit'] = array(
            '#type' => 'submit',
            '#value' => 'Filter',
          );
return $form;
 }

In one of my node--nid.tpl.php, I am rendering this form as

 $arr = drupal_get_form('report_page_form_form');
 print drupal_render($arr); 

I am writing an SQL query in the same node--nid.tpl.php file to fetch data from DB.

SELECT TITLE FROM REPORT WHERE ....

I need to pass form submitted values to this query. Can anyone help me to do it.

2

You would get the values of the submitted form in hook_form_submit

function MY_MODULE_NAME_form_submit($form, &$form_state) {
         //your code here
        } 

You would get all the required values in $form_state['values']

  • Thanks Aparna. i need the $form_state['values'] in my node--nid.tpl.php. Is that possible instead of new module. – drup Jul 30 '15 at 9:35
  • 1
    You could try report_page_form_form_submit. I hope it will work – Aparna Jul 30 '15 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.