You are here

function spaces_taxonomy_form_alter in Spaces 6

Same name and namespace in other branches
  1. 6.3 spaces_taxonomy/spaces_taxonomy.module \spaces_taxonomy_form_alter()
  2. 6.2 spaces_taxonomy/spaces_taxonomy.module \spaces_taxonomy_form_alter()
  3. 7.3 spaces_taxonomy/spaces_taxonomy.module \spaces_taxonomy_form_alter()
  4. 7 spaces_taxonomy/spaces_taxonomy.module \spaces_taxonomy_form_alter()

File

spaces_taxonomy/spaces_taxonomy.module, line 219

Code

function spaces_taxonomy_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'taxonomy_form_term':
      $vid = variable_get('spaces_taxonomy_vid', 0);

      // Add delete submit handler
      if (isset($form_state['confirm_delete'])) {
        $form['#submit'][] = '_spaces_taxonomy_form_delete';
      }
      else {
        if ($vid != 0 && $form['vid']['#value'] == $vid) {

          // Get default value for prefix field
          $tid = isset($form['tid']['#value']) ? $form['tid']['#value'] : 0;
          $space = spaces_load('taxonomy', $tid);
          $form['spaces'] = array(
            '#type' => 'fieldset',
            '#title' => t('Spaces'),
            '#tree' => FALSE,
            '#weight' => 0,
          );

          // Add context prefix form
          $form['spaces']['purl'] = purl_form('spaces_taxonomy', $tid, $space->purl);

          // Add presets form
          $form['spaces']['spaces_preset'] = spaces_form_presets($space);

          // Add custom submit handler
          $form['#submit'][] = '_spaces_taxonomy_form_submit';
        }
      }
      break;
  }
}