开发者

How to pass variable from form submit function to page callback function in Drupal 6

I have a Drupal form and a submit function that processes that form. 开发者_运维知识库I would like to pass data from the submit function to the page callback function that loads after the form was processed.


Well, 10 months later of Drupal development later, I believe the $_SESSION variable is the only way of doing this. Drupal doesn't have any special tools for this.


It's a bit "late" but I feel to propose a new solution as I just found this post. Submit and Callback functions share the same $form and $form_state variables. If you want to pass a variable from one to another you can do it this way:

function YOUFORM_submit($form, &$form_state) {
  // Set the variable
  $form_state['values']['NEW_VAR'] = NEW_VALUE;
}


function YOUFORM_callback($form, &$form_state) {
  // Get the variable
  $new_value = $form_state['values']['NEW_VAR'];
}

More informations here : $form_state keys

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜