Hi,

I was wondering if anyone could tell me where the form is for uploading an image as I want to make the category drop-down (to select the appropriate Image gallery) a compulsory field.

Any help would be greatly appreciated.

Thank you very much.

Sarah

Comments

vm’s picture

There isn't one. you would have to alter the image.module file or override the form at theme level.

scarer’s picture

what do you mean by alter? the image.module file is in php. it doesn't contain any form fields. is there a way to specify it in the php?

vm’s picture

: ) it does contain form fields, just not HTML form fields.

example pulled directly from the image.module file:

function image_settings_sizes_form() {
  $sizes = _image_get_sizes();

  $form['#type'] = 'item';
  $form['#description'] = t('Select various pixel dimensions, "thumbnail" and "preview" are required.');
  $form['#tree'] = TRUE;
  $form['#theme'] = 'image_settings_sizes_form';
  for ($i = 0; $i < 5; $i++) {
    $form[$i]['label'] = array('#type' => 'textfield', '#default_value' => $sizes[$i]['label'], '#size' => 25);
    if (in_array($sizes[$i]['label'], _image_required_sizes())) {
      $form[$i]['label']['#attributes'] = array('disabled' => 'disabled');
      $form[$i]['label']['#value'] = $sizes[$i]['label'];
    }
    $form[$i]['width'] = array('#type' => 'textfield', '#default_value' => $sizes[$i]['width'], '#size' => 5, '#maxlength' => 5);
    $form[$i]['height'] = array('#type' => 'textfield', '#default_value' => $sizes[$i]['height'], '#size' => 5, '#maxlength' => 5);
  }

  return $form;
}

you will need to read the handbooks about how to customize drupal forms to learn how to alter them.

form generation = http://api.drupal.org/api/5/group/form

hook form = http://api.drupal.org/api/5/function/hook_form

nevets’s picture

Instead you can make the vocabulary (taxonomy/category) required.

Goto to 'Administer'

Under 'Content management' select 'Categories'

Find the category that applies to images (image will be in type column) that you want required, click on 'edit vocabulary'

Find the 'Required' checkbox (toward the end of the form) and check it.

vm’s picture

ahh yes! follow nevets advice if all you want to do is force a category, I thought the first part of your question was about to to alter the forms themselves AND and force a category.

scarer’s picture

thanks for all your help. did the trick nicely :)