You are here

function hashtags_form_alter in Hashtags 6

Same name and namespace in other branches
  1. 8 hashtags.module \hashtags_form_alter()
  2. 6.2 hashtags.module \hashtags_form_alter()
  3. 7.2 hashtags.module \hashtags_form_alter()

Implementation of hook_form_alter().

File

./hashtags.module, line 7

Code

function hashtags_form_alter(&$form, $form_state, $form_id) {
  $vid = variable_get('hashtags_vocabulary', '');
  $voc = taxonomy_vocabulary_load($vid);

  // Hide hashtag textfield from node edit page;
  // check only for hashtag content types.
  if (isset($form['type']) && isset($form['#node']) && in_array($form['type']['#value'], $voc->nodes) && $form['type']['#value'] . '_node_form' == $form_id) {
    drupal_add_js("if (Drupal.jsEnabled) { \$(document).ready(function() { \$('div#edit-taxonomy-tags-{$vid}-wrapper').css('display', 'none'); }); }", 'inline');
  }
  elseif (isset($form['vid']) && $form['vid']['#value'] == $vid) {

    // Hide critical options from hashtag vocabulary.
    if ($form_id == 'taxonomy_form_vocabulary') {
      $form['help_hashtags_vocab'] = array(
        '#value' => t('This is the designated hashtags vocabulary. Some of the normal vocabulary options have been removed.'),
        '#weight' => -1,
      );
      $form['identification']['description']['#access'] = FALSE;
      $form['identification']['help']['#access'] = FALSE;
      $form['content_types']['nodes']['#required'] = TRUE;
      $form['settings']['#access'] = FALSE;
      unset($form['delete']);
    }
    elseif ($form_id == 'taxonomy_form_term') {
      $form['advanced']['parent']['#access'] = FALSE;
    }
  }
}