You are here

function disable_breadcrumbs_form_alter in Disable breadcrumbs 6

Same name and namespace in other branches
  1. 7 disable_breadcrumbs.module \disable_breadcrumbs_form_alter()

Implementation of hook_form_alter().

File

./disable_breadcrumbs.module, line 84
Disable breadcrumbs

Code

function disable_breadcrumbs_form_alter(&$form, &$form_state, $form_id) {
  $enabled_content_types = variable_get('disable_breadcrumbs_node_types', array());

  // Only perform alteration if node edit form, content type is checked in settings, and user has permissions
  if (strpos($form_id, "_node_form") !== FALSE && isset($form['#node']) && in_array($form['#node']->type, $enabled_content_types, TRUE) && user_access('administer breadcrumbs')) {
    $form['breadcrumb'] = array(
      '#type' => 'fieldset',
      '#title' => t("Breadcrumbs"),
    );
    $form['breadcrumb']['disable_breadcrumb'] = array(
      '#type' => 'checkbox',
      '#title' => t("Disable breadcrumb"),
      '#return_value' => 1,
      '#default_value' => $form['#node']->disable_breadcrumb,
      '#description' => t("Hide the breadcrumb when this node is viewed"),
    );

    // Append another submit function to update disable_node field in node table
    $form['#submit'][] = 'disable_breadcrumbs_node_form_submit';
  }
}