Drupal - Webforms作为块 - 修改操作 [英] Drupal - Webforms as Block - Modifying Action

查看:229
本文介绍了Drupal - Webforms作为块 - 修改操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Drupal 7.15,并将Webform设置为联系人页面(基本页面)中包含的一个块。基本的联系人页面具有可编辑的侧栏内容,然后是Webform块作为主要内容。我遇到的问题是提交Webform会自动将别名一般查询而不是联系我们别名联系我们。我希望它返回到基本页面,与我们联系,并提供任何验证错误和/或确认消息。



似乎表单操作始终是Webform别名,但是当我尝试将别名更改为基本页面联系我们别名(contact-us),它说这个别名已经在使用。



如果没有为错误或成功确认创建单独的页面,我如何修改操作以返回原始页面,并提交任何消息?事实上,我不想让我们JS来设置表单动作。如果错误/成功消息没有传递给它,这可能甚至不能帮助我。



如果您想查看,这里是测试服务器:

  http://69.160.59.20/contact-us 

任何和所有的帮助非常感谢



感谢所有

解决方案

表单操作可以使用form_alter钩子如下所示:

  my_module_form_alter($ form,$ form_state,$ form_id){
if($ form_id ==' webform_id_form'){
$ form ['#action'] = url('comment / reply /'。$ edit ['nid']);
}
}

如果您使用Drupal 7,请跳过表单id检查并尝试:

  my_module_form_form_id_alter($ form,$ form_state){
}

如果你不知道如何找到表单id,只需使用上面的函数打印语句:

  my_module_form_alter($ form,$ form_state,$ form_id){
print($ form_id);
}

,表单id将是其中的webform一词。 / p>

这里的api格式的更多细节:
http://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7#action


I am using Drupal 7.15, and have a Webform setup as a block that gets included on the Contact page (a basic page). The basic Contact page has editable sidebar content and then the Webform block as the main content. The problem I am having is on submission the Webform goes to its own alias 'general-inqueries' rather than the Contact us alias 'contact-us'. I want it to return to the basic page Contact Us with any validation errors and/or confirmation message.

It seems the form action is always the Webform alias, however when I try to change the alias to the basic page Contact Us alias (contact-us), it says this alias is already in use.

Without creating a separate page for errors or success confirmation, how can I modify the action to return to the original page with any messages on submit? I would prefer not to us JS to set the form action after the fact. That might not even help me anyway if the error/success messages are not passed to it.

Here is the testing server if you would like to take a look:

http://69.160.59.20/contact-us

Any and all help is much appreciated!

Thanks all

解决方案

Form actions can be set using a form_alter hook. Something like:

my_module_form_alter($form, $form_state, $form_id) {
  if ($form_id == 'webform_id_form') {
    $form['#action'] = url('comment/reply/'. $edit['nid']);
  }
}

If you are using Drupal 7 skip the form id check and try:

my_module_form_form_id_alter($form, $form_state) {
}

if you don't know how to find the form id just use the above function with a print statement:

my_module_form_alter($form, $form_state, $form_id) {
  print($form_id);
}

and the form id will be the one with the word webform in it.

More details on the form api here: http://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7#action

这篇关于Drupal - Webforms作为块 - 修改操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆