You are here

function taxonomy_image_form_alter in Taxonomy Image 6

Same name and namespace in other branches
  1. 5 taxonomy_image.module \taxonomy_image_form_alter()

File

./taxonomy_image.module, line 534
taxonomy_image.module Simple module for providing an association between taxonomy terms and images. Written by Jeremy Andrews <jeremy@kerneltrap.org>, May 2004.

Code

function taxonomy_image_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'taxonomy_form_term':

      // Don't show Term-Image fieldset if we're deleting this term.
      if ($form_state['confirm_delete']) {
        return;
      }
      $preview = @taxonomy_image_display($form['tid']['#value']);
      $form['#attributes'] = array(
        'enctype' => 'multipart/form-data',
      );
      $form['taxonomy_image'] = array(
        '#type' => 'fieldset',
        '#title' => t('Term Image'),
        '#collapsible' => TRUE,
        '#collapsed' => empty($preview),
      );
      if ($preview) {
        $form['taxonomy_image']['current_image'] = array(
          '#type' => 'fieldset',
          '#title' => t('Current Image'),
        );
        $form['taxonomy_image']['current_image']['image'] = array(
          '#value' => $preview,
        );
        $form['taxonomy_image']['current_image']['taxonomy_image_current_image_delete'] = array(
          '#type' => 'checkbox',
          '#title' => t('Delete'),
          '#prefix' => '<div class="taxonomy_image_checkboxes">',
          '#suffix' => '</div>',
        );
      }
      $form['taxonomy_image']['new_image']['taxonomy_image_upload'] = array(
        '#type' => 'file',
        '#title' => t('Upload image'),
        '#size' => 60,
        '#description' => t("The image file you wish to associate this term."),
      );
      $form['taxonomy_image']['taxonomy_image_external'] = array(
        '#type' => 'textfield',
        '#title' => t('Use external image'),
        '#default_value' => $curr_path,
        '#cols' => 60,
        '#description' => t('Enter the URL of an image to copy to this site. URL must end with one of these extensions: @exts.', array(
          '@exts' => TAXONOMY_IMAGE_IMAGE_EXTENSIONS,
        )),
        '#prefix' => '<strong>' . t('or:') . '</strong>',
      );
      $form['#validate'] = array(
        'taxonomy_image_validate_external',
      );
      $form['submit']['#weight'] = 10;
      $form['delete']['#weight'] = 10;
      break;
  }
  return $form;
}