开发者

Drupal Module Development: How to Communicate between form_submit and page handler functions

I am writing a module and I need to retrieve values set in a form_s开发者_StackOverflow社区ubmit function from a page handler function. The reason is that I am rendering results of a form submit on the same page as the page handler.

I have this working, but I am using global variables, which I don't like. I'd like to be able to use the $form_state['storage'] for this, but can't since I don't have access to the $form_state variable from the page handler.

Any suggestions?


RE: Drupal: How to Render Results of Form on Same Page as Form

You don't have access to $form_state in the page handler, but I think it might be available to your form builder function automatically. See if you can dump it out using something like

function _ncbi_subsites_show_paths_form($form_state) {
  dsm($form_state);
 // everything else
}

Another possibility, though not much better than using globals, would be to use Drupal's variable_set() and variable_get functions.

If you're dealing with just a single value you could pass it to page as a URL argument from a $form['#redirect'] in the submit handler.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜