5

我想从特定的 Drupal 网络表单中删除提交按钮,这可能吗?如果可以,我该怎么做?

如果可能的话,我还想从同一个表单中删除上一个按钮。

4

6 回答 6

7

如@googletop 所示,您需要使用 hook_form_alter() 来定位和更改该表单

要取消提交,可以在自定义模块中执行以下操作:

<?php
function my_custom_module_form_alter(&$form, &$form_state, $form_id) {

  if ($form_id == 'webform_client_form_130') {
    if ($thiscondition && $thatcondition){
      unset($form['actions']['submit']);
    }
  }
}
?>

与“上一个”按钮相同,您只需要在表单数组中找到它

于 2011-03-08T13:58:37.880 回答
4
  1. 复制文件webform-form.tpl.php
  2. 将其重命名为webform-form-{nid}.tpl.phpnid 等于您的节点 ID
  3. 编辑 - 在之后添加一行print drupal_render($form['submitted']);
    添加这一行:unset($form['actions']['submit']);

这个对我有用。

于 2012-12-11T21:18:55.143 回答
1

您可以更改 drupal 中的任何形式,使用hook_form_alter.

于 2011-03-08T11:24:38.430 回答
1

如果您想快速修复原型等,那么您可以在 CSS 中隐藏按钮。

.block-webform .form-actions {
visibility:hidden;
}

隐形按钮仍会占用空间,但您将无法看到它。

于 2011-09-08T01:59:34.757 回答
0

我在 中使用了这些简单的 php 行,webform-form.tpl.php因为创建 awebform-form-{nid}.tpl.php或 a webform-form-[nid].tpl.php(在模板文件中指定)不起作用。所以我只是在 webform 上使用了 if 条件$nid来取消设置特定 webform 节点上的提交按钮。

print drupal_render($form['submitted']);
$arrayWithoutSubmitButton = array( 29, 30, 31, 32);
if( in_array( $nid, $arrayWithoutSubmitButton)){
    unset($form['actions']['submit']);
}
于 2013-10-02T07:55:01.997 回答
0

感谢这一点,对我来说,Etno 的解决方案有效:其他解决方案由于某种原因不起作用。

我唯一要补充的是,提到的文件在“/sites/all/modules/webform/templates/webform-form.tpl.php”中,而不是“/drupal/sites/all/modules/中的文件” webform/templates/webform-form.tpl.php”(如果你有这样的文件)——我花了一段时间才弄清楚:)

于 2015-04-07T15:43:03.473 回答