Hi All,
I am developing a module. I added form fields in xxx_form.While displaying the form it displays Preview and Submit buttons that I do not want. Is there any way to remove it

Comments

hook_form_alter()

You mention a preview button... Are you developing a custom content type?

I've never tried it myself, but I think it should be possible to use hook_form_alter() to remove the buttons. To remove the buttons simple use unset($form['the_button_name']);

If all you need is to get rid of the preview button, you can disable the need for preview somewhere in the settings (I don't remeber exatly where...).

---------------------------
Drupal makes a great job of hosting my site Nyfiken vital | Kost, hälsa & skönhet.

Drupal makes a great job of hosting my site Nyfiken vital | Kost, hälsa & skönhet.

=-=

the preview button cannot be disabled in adminsiter -> post settings.
however, It can be set to be optional or required, but in the end the button will still show even though it can be bypassed.

Hooking form_alter to disable form buttons

You can disable some button changing the #disabled attribute. Example to disable 'Delete' button on node edit:

function MODULE_form_alter($form_id, &$form) {

  switch ($form_id) {

    case 'TYPE_CONTENT_node_form':
      $form['delete']['#disabled'] = true;
      break;
  }
}

If you prefer hide the button:

      unset($form['delete']);

Rafa Couto (caligari)
mailto: rafacouto@ gmail.com
GPG: http://caligari.treboada.net/gpg

Hooking form_alter to disable form buttons

in which file should I look for it??

***

ok, I made it. thanks!

At your module or another

At your module or another one. form_alter is a global hook: http://api.drupal.org/api/5/function/hook_form_alter

Rafa Couto (caligari)
mailto: rafacouto@ gmail.com
GPG: http://caligari.treboada.net/gpg

This is exactly right. The

This is exactly right. The form name that you'll want to hook for custom node types is NODETYPE_node_form, where nodetype is the key of the array you return in hook_node_info().