function tripal_example_form_alter

2.x tripal_example.module tripal_example_form_alter(&$form, &$form_state, $form_id)

Implementation of hook_form_alter()

Allows a module to alter any form prior to it being rendered. For more details about Drupal's Form API see this page:

https://api.drupal.org/api/drupal/includes!form.inc/group/form_api/7

File

tripal_example/tripal_example.module, line 345
This file contains all Drupal hooks for the module other than any node hooks and block hooks. Those go in the [module name].chado_node.inc file and [module_name].blocks.inc respectively

Code

function tripal_example_form_alter(&$form, &$form_state, $form_id) {

  if ($form_id == "chado_example_node_form") {

    // EXPLANATION:  The hook_form_alter() Drupal hook is used to alter a form
    // before it is displayed. This allows any module to provide new form
    // elements or change the form that another module creates. We do not need
    // to alter a form created by another module, but we do want to alter the
    // form for our new node type. For example, all node types will
    // automatically have a 'Preview' button. For inserting or updating data
    // for Chado we don't really need a Preview button and it complicates the
    // form. So, we use the following code to disable the Preview button. If
    // you want to keep the preview button then remove this code. turn of
    // preview button for insert/updates
    $form['actions']['preview']['#access'] = FALSE;

    // EXPLANATION: Drupal always adds a 'body' field to all node types.
    // Our node type doesn't use the 'body' field so we remove it from the form.
    unset($form['body']);
  }
}