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


基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01