Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Drupal 6中webform的附加提交事件处理程序_Php_Drupal 6 - Fatal编程技术网

Php Drupal 6中webform的附加提交事件处理程序

Php Drupal 6中webform的附加提交事件处理程序,php,drupal-6,Php,Drupal 6,我在我的网站上使用Drupal 6.19和webform模块。在一个特定的表单上,我想对输入的值进行一些额外的处理,因此我创建了一个模块并实现了hook_form_alter,并将我自己的函数mymodule_webform_submit添加到提交事件处理程序列表中 假设表单中有两个字段,分别具有字段键值name和address。如何在mymodule\u webform\u submit函数中打印这些字段的值?。请举个例子。下面是到目前为止我的代码 <?php function

我在我的网站上使用Drupal 6.19和webform模块。在一个特定的表单上,我想对输入的值进行一些额外的处理,因此我创建了一个模块并实现了hook_form_alter,并将我自己的函数mymodule_webform_submit添加到提交事件处理程序列表中

假设表单中有两个字段,分别具有字段键值name和address。如何在mymodule\u webform\u submit函数中打印这些字段的值?。请举个例子。下面是到目前为止我的代码

<?php
    function mymodule_form_alter(&$form, &$form_state, $form_id) {
      if($form_id == 'webform_client_form_8') {

         $form['#submit'][] = 'mymodule_webform_submit';

      }

    }

    function mymodule_webform_submit(&$form,&$form_state) {
      drupal_set_message($form_state['values']['name']);

    }


?>

请帮忙
谢谢

您缺少提交函数的参数。添加这些值后,您的值应为$form_state['values']。应该是这样的:

function mymodule_webform_submit($form, &$form_state) {
  print $form_state['values']['name'];
  print $form_state['values']['address'];
}

但你想做什么就做什么,里面有价值观。只要确保您有正确的元素键。您可以通过放置var_export($form_state['values'])来查看可用的内容;退出();在函数内部并提交表单。

谢谢jon的回复。我使用drupal_set_消息打印了文本字段的值,但它没有显示任何内容。此外,尝试按照您的建议进行打印,但在提交表单之前,它不会打印用户输入的值。我已编辑了上面的代码以反映所做的更改。请提供帮助。您可以尝试在提交函数中使用“var_export($form_state['values'));exit;”打印表单提交的所有内容。这将向您显示结构和可用内容。