【问题标题】:How can I pass a parameter to the form submit handler in Drupal如何将参数传递给 Drupal 中的表单提交处理程序
【发布时间】:2012-02-23 10:59:14
【问题描述】:

我正在开发一个适用于多种表单的模块。我需要将 $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?

谢谢!

【问题讨论】:

    标签: drupal drupal-7 drupal-modules drupal-hooks drupal-forms


    【解决方案1】:

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

    【讨论】:

    • 发现form_id已经是所有字段中的隐藏字段了....
    猜你喜欢
    • 1970-01-01
    • 2014-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-02
    • 1970-01-01
    • 2012-08-30
    相关资源
    最近更新 更多