Using Hook_form_alter on webform submitted values(在 webform 提交的值上使用 Hook_form_alter)
问题描述
Drupal 7. 网络表单 3.x.
Drupal 7. Webforms 3.x.
我正在尝试在提交时修改 webform 组件值.我制作了一个名为mos"的自定义模块并将此代码添加到其中.
I am trying to modify a webform component value on submit. I made a custom module called 'mos' and added this code to it.
function mos_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'webform_client_form_43') {
dsm($form['#node']->{'webform'}['components']['1']);
$form['#submit'][] = 'mos_contact_us_submit';
}
}
function mos_contact_us_submit($form, &$form_state) {
$form['#node']->{'webform'}['components']['1'] = 'working@mos.com';
}
但是,当我查看数据库中的结果时,会存储常规的非覆盖值.你能帮我知道我做错了什么吗?
However when I look at the results in the database the regular, non-overridden value is stored. Can you help let me know what I am doing wrong?
最终我想取输入值并根据提供的内容输出一个电子邮件地址(例如.24 变成 bob@somewhere.com)但我想我可以自己弄清楚这部分.
Eventually I want to take the input value and output an email address based on what was provided (for example. 24 turns into bob@somewhere.com) But I think I can figure this part out myself.
推荐答案
你应该先提交.
array_unshift(
$form['actions']['submit']['#submit'],
'mos_contact_us_submit'
);
但是,如果你想改变form_state中的一些变量,你应该使用自定义的_valadate函数.
However, if you want to change some variables in form_state, you should to using custom _valadate function.
这篇关于在 webform 提交的值上使用 Hook_form_alter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 webform 提交的值上使用 Hook_form_alter


基础教程推荐
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01