I want to disable the preview and delete buttons on node edit form.I have used the following code.But it is not working. where am i wrong with this?

function mymodule_form_alter(&$form, $form_state, $form_id) {
// Check for a particular content type's node form.
  if ($form_id == 'node-gallery-item-node-form') {

    unset ($form['edit-preview']);
    unset ($form['edit-delete']);

  • Use $form['actions']['preview']['#access'] = FALSE; I'm going to post an answer Jun 27, 2014 at 6:38

2 Answers 2


Since you are not checking for any particular condition in your code, I would suggest that you remove the preview option from the content type settings.


Regarding the delete button if you can do it using permissions, you should always do it using permissions. If you do not want to revoke the permission but just want to hide for a particular screen then use

$form['actions']['delete']['#access'] = FALSE;
  • Yes.I have removed preview option form the content type settings and set above code.Its working.Thanks!
    – 12345
    Jun 27, 2014 at 7:36
  • There is a typo dlete to delete
    – Rupesh
    Jun 27, 2014 at 9:34

For disabling preview you can go through your content-type edit page under submission form setting tab.Here you can disable Preview before submitting option. For delete you can go through permission and uncheck delete permission for your specific content-type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.