function uc_catalog_form_alter in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_catalog/uc_catalog.module \uc_catalog_form_alter()
Implements hook_form_alter().
Adds an image field to the catalog's taxonomy term form.
File
- uc_catalog/
uc_catalog.module, line 343 - Ubercart Catalog module.
Code
function uc_catalog_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'taxonomy_form_term' && $form['vid']['#value'] == variable_get('uc_catalog_vid', 0)) {
$form['#attributes'] = array(
"enctype" => "multipart/form-data",
);
$form['identification']['name']['#weight'] = -1;
$form['identification']['image']['#weight'] = 0;
$form['identification']['image']['image'] = array(
'#type' => 'file',
'#title' => t('Image'),
'#weight' => 0,
);
$image = isset($form['tid']['#value']) ? uc_catalog_image_load($form['tid']['#value']) : FALSE;
$imagecache = module_exists('imagecache');
if ($image) {
if ($imagecache) {
$image_display = theme('imagecache', 'uc_category', $image->filepath);
}
else {
$image_display = theme('image', $image->filepath, t('Term image'));
}
$form['identification']['image']['remove'] = array(
'#type' => 'checkbox',
'#title' => t('Remove category image: !image', array(
'!image' => $image_display,
)),
'#weight' => 1,
);
}
if (!$imagecache) {
$form['identification']['image']['image']['#description'] = t('The image will not be resized. Consider installing <a href="@url">Image cache</a>.', array(
'@url' => url('http://drupal.org/project/imagecache'),
));
}
$form['identification']['description']['#description'] = t('A description of the term. Displayed to customers at the top of catalog pages.');
}
}