0

如果我正在制作一个模块,并且想要有两个自定义路径:

path/path/path/index.htm(调用 drupal_get_form)

并发布到

路径/路径/路径/result.htm

你是怎样做的?我在第二条路径上得到 404。我很容易通过第一条路径获得表格和我想要的东西。我要做的就是将表单结果主题化为drupal 表并在此处显示。

4

2 回答 2

1

这看起来是个不错的选择:http ://drupal.org/node/290462

<?php
/**
* Implementation of hook_form_alter().
*/
function jm_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) {
    $form['buttons']['submit']['#submit'][] = 'jm_redirect_handler';
  }
}

/**
* Attaches the redirect to the submitted form.
*
* @param unknown_type $form
* @param unknown_type $form_state
* @return unknown
*/
function jm_redirect_handler($form, &$form_state) {
  if ($form_state['nid']) {
    // reloading as I do not know the node type context. You probably do not need to :), just set the redirect using $form_state['nid']
    $node = node_load(array('nid' => $form_state['nid']));
    switch($node->type) {
      case 'project':
        $form_state['redirect'] = 'projects/'. $node->nid;
    }
  }
}
?>
于 2010-05-11T08:12:22.393 回答
0

知道了。实施了 AHAH 和所有这些。在我的回调中忘记了一个参数。

于 2010-05-13T15:25:33.577 回答