5

I'd like to remove the submit button from a specific Drupal webform, is this possible and if so how do I do it?

I'd also like to remove the previous button if possible as well from the same form.

rdans
  • 2,179
  • 22
  • 32
jeremy
  • 201
  • 2
  • 5
  • 14

6 Answers6

7

You'll need to target and alter that form with hook_form_alter() as indicated by @googletop

To unset the submit, something like this in a custom module would work:

<?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']);
    }
  }
}
?>

Same for the "previous" button, you'll just need to find it in the form array

jpstrikesback
  • 2,300
  • 14
  • 18
4
  1. Copy the file webform-form.tpl.php
  2. Rename it webform-form-{nid}.tpl.php where nid equals your node ID
  3. Edit - add just one line after print drupal_render($form['submitted']);,
    add this line: unset($form['actions']['submit']);

It works for me.

Olle Sjögren
  • 5,315
  • 3
  • 31
  • 51
Alex
  • 41
  • 1
1

You can alter any form in drupal, using hook_form_alter.

googletorp
  • 33,075
  • 15
  • 67
  • 82
1

If you'd like a quick fix for a prototype, etc then you could just hide the button in CSS.

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

The invisible button will still take up a space, but you won't be able to see it.

barryclark
  • 11
  • 1
0

I used these simple php lines in the webform-form.tpl.php because creating a webform-form-{nid}.tpl.php or a webform-form-[nid].tpl.php (as specified in the template file) does NOT work. So I simply used an if condition on $nid webform just to unset the submit button on specific webform nodes.

print drupal_render($form['submitted']);
$arrayWithoutSubmitButton = array( 29, 30, 31, 32);
if( in_array( $nid, $arrayWithoutSubmitButton)){
    unset($form['actions']['submit']);
}
etno
  • 1
  • 1
0

Thanks for this and for me, Etno's solution worked: the others didn't work for some reason.

The only thing I would add to this is that the file mentioned is in "/sites/all/modules/webform/templates/webform-form.tpl.php" and NOT the file in "/drupal/sites/all/modules/webform/templates/webform-form.tpl.php" (if you have such a file) - it took me a while to figure that out :)