1
$nid = db_insert('tennis_vana')
  ->fields(array(   'firstname' => $first,   'lastname' => $last   ))
  ->execute(); 

unset($form); 
$form_state['rebuild'] = TRUE; 

drupal_set_message("you data has been saved");

$details=project_list1();

this is not working. My requirement is, I want to call and display information from after submit.

9
  • could you explain a little more? Question doesnot seem clear. Jun 29, 2013 at 6:23
  • function firstest_menu() { return $items; } function firstest_form($form_state) { //code return $form; } function firstest_form_submit($form, &$form_state) { $nid = db_insert('tennis_vana') ->fields(array( 'firstname' => $first, 'lastname' => $last )) ->execute(); unset($form); $form_state['rebuild'] = TRUE; drupal_set_message("you data has been saved"); $details=project_list1();//here i want to call following functions. } function project_list1() { //code return $output; } Jun 29, 2013 at 6:29
  • You can call project_list() in submit. Are you sure it is returning some $output ? Have you tried calling this function other place than submit ? Jun 29, 2013 at 6:35
  • yes..i have tried. Jun 29, 2013 at 6:43
  • yes,i have tried..........function project_list1() { $header = array('ID', 'Type', 'Name'); $data = array(); # set the database table $query = db_select('tennis_vana', 'p'); # configure the query $query->fields('p', array('firstname','lastname')); # execute the query $results = $query->execute(); foreach ($results as $row) { $data[] = array($row->firstname, $row->lastname, ); } $output = theme('table', array('header' => $header, 'rows' => $data )); return $output; } Jun 29, 2013 at 6:44

1 Answer 1

1

If you want to call the function after submit of the form.

Add this part in hook_menu:

function MYMODULE_menu(){

    $items['project'] = array(
    'title' => 'Project List' ,
    'page callback' => 'project_list1',
    'access callback' => TRUE,
    'menu_name' => 'devel',
    'type' => MENU_CALLBACK,
    );

 return $items;

}

If you want the menu to appear in main menu you can make these changes:

     'menu_name' => 'main-menu',
     'type' => MENU_NORMAL_ITEM,



Your  function here:


  function project_list1(){
     /////code
    }

And then in your submit function, you can directly add:

  //Add this in the last line of your submit function
   drupal_goto('project');

This will directly go to the path 'project' and call your function

project_list1()

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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