如何将参数传递给 Drupal 中的表单提交处理程序

发布于 2025-01-08 04:29:40 字数 435 浏览 4 评论 0原文

我正在开发一个对于多种表单来说很常见的模块。我需要将 $form_id 作为参数传递给提交处理程序,并在提交函数中相应地设置表单值。

function ppi_form_alter(&$form, &$form_state, $form_id){

  $form['#submit'][]="action_form_submit";

}

function action_form_submit($form, &$form_state) {
  //here I need to get the form_id of the form and form_set_value accordingly ... How can I know the form value?
}

有没有办法知道 form_submit 中的 form_id ?

谢谢!

I am working on a module which is common for a number of forms. I need to pass the $form_id as a parameter to the submit handler and set the form values accordingly in the submit function.

function ppi_form_alter(&$form, &$form_state, $form_id){

  $form['#submit'][]="action_form_submit";

}

function action_form_submit($form, &$form_state) {
  //here I need to get the form_id of the form and form_set_value accordingly ... How can I know the form value?
}

Is there a way to know the form_id in form_submit ?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话 2025-01-15 04:29:40

在hook_form_alter()中将其设置为隐藏字段,
然后像使用提交处理程序中的任何其他字段一样使用它

Set it as a hidden field in the hook_form_alter(),
and then use it as you would any other field in the submit handler

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文