Hello, I have problems to pass a simple variable as a parameter to a function.
I have the following code:

function prova_submit($form, &$form_state){
  $fi = $form_state['values']['filtro'];  
 drupal_goto('tablePage');
 fiY=tablePage($fi)
}

function tablePage($fiY){
var_dump($fiY)
}

Doing this, the var_dump($fiY) is NULL and
Warning: Missing argument 1 for tablePage(),
How can I pass the variable into the tablePage?
Thanks in advance
Stefania

Comments

bboldi’s picture

This code does not look good...

1st of all, this line:

fiY=tablePage($fi)

what is fiY ? if should be $fiY.

second of all to use drupal_goto, you need to define a menu item first - you cannot use drupal_goto with a function ...

then: I don't thing that any code will be executed after drupal_goto call because it calls drupal_exit($url); and that function has exit; in it, which will terminate the script...

take a look at these articles:

http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_go...
http://api.drupal.org/api/drupal/includes--menu.inc/group/menu/7
http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...

nicksanta’s picture

Hmm, I'm not quite sure what you're trying to do here, but I'll take a guess that you're trying to do some submission tasks in the tablePage() function.

I have not done much C before, but drupal_goto is a function to redirect the user's browser. It does not work the same as goto in other languages.

Try something like this:

<?php
/**
  * Submission handler
  */
function prova_submit($form, &$form_state) {
  $fi = $form_state['values']['filtro'];
  $return_value = tablePage($fi);
  // If you want to redirect the browser at the end of submission, do something with the following example:
  if ($return_value) {
    $form_state['redirect'] = 'internal/path';
  }
}

/**
  * Submission helper function
  */
function tablePage($fi) {
  // See whether the user submitted a number
  if (is_numeric($fi)) {
    return TRUE;
  }
  return FALSE;
}
?>

----------------------
Nick Santamaria