You are here

function ad_form_alter in Advertisement 5.2

Same name and namespace in other branches
  1. 5 ad.module \ad_form_alter()
  2. 6.3 ad.module \ad_form_alter()
  3. 6 ad.module \ad_form_alter()
  4. 6.2 ad.module \ad_form_alter()
  5. 7 ad.module \ad_form_alter()

Drupal _form_alter() hook.

File

./ad.module, line 794
An advertising system for Drupal powered websites.

Code

function ad_form_alter($form_id, &$form) {
  if ($form_id == 'taxonomy_form_vocabulary') {

    // Remove taxonomy form options not applicable for ad groups.
    if ($form['vid']['#value'] == _ad_get_vid()) {
      $form['help_ad_vocab'] = array(
        '#value' => t('This vocabulary was automatically created for use by the ad module.  Only applicable options are available.'),
        '#weight' => -1,
      );
      $form['nodes']['ad'] = array(
        '#type' => 'checkbox',
        '#title' => t('ad group'),
        '#value' => 1,
        '#attributes' => array(
          'disabled' => '',
        ),
        '#description' => t('Type %type is required to use this vocabulary.', array(
          '%type' => t('ad group'),
        )),
      );
      $form['tags']['#description'] = t('If enabled, ads are categorized by typing ad group names instead of choosing them from a list.');
      $form['multiple']['#description'] = t('If enabled, allows ads to have more than one ad group (always true for free tagging).');
      $form['required']['#description'] = t('If enabled, every ad <strong>must</strong> be assigned to at least one ad group.');
      $form['hierarchy'] = array(
        '#type' => 'value',
        '#value' => 0,
      );
      unset($form['relations']);
    }
    else {
      unset($form['nodes']['ad']);
    }
  }
  else {
    if ($form_id == 'taxonomy_form_term') {
      if ($form['vid']['#value'] == _ad_get_vid()) {
        $form['name']['#title'] = t('Ad group name');
        $form['name']['#description'] = t('The name for this ad group.  Example: "Linux".');
        $form['description']['#description'] = t('A description of the ad group.');
        $form['description']['#required'] = TRUE;
        $form['weight']['#description'] = t('In listings, the heavier ad groups will sink and the lighter ad groups will be positioned nearer the top.');
        unset($form['synonyms']);
      }
    }
  }
}