You are here

function exif_field_widget_settings_form in Exif 7

Implementation of hook_widget_settings().

File

./exif.module, line 530

Code

function exif_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $defaults = field_info_widget_settings($widget['type']);
  $settings = array_merge($defaults, $widget['settings']);
  $form = array();
  if ($widget['type'] == 'exif_readonly') {
    $exif_fields = _exif_field_widget_retrieve_exif_fields();
    $default_exif_value = _exif_get_field_widget_retrieve_exif_field_default_value($widget);
    $default_exif_separator_value = _exif_get_field_widget_retrieve_exif_field_separator_default_value($widget);
    if ($instance['entity_type'] == 'node') {
      $image_fields = _exif_field_widget_retrieve_image_field_from_bundle($instance['entity_type'], $instance['bundle']);
      $default_image_value = _exif_get_field_widget_retrieve_image_field_default_value($widget, $image_fields);
      $form['image_field'] = array(
        '#type' => 'radios',
        '#title' => t('image field to use to retrieve data'),
        '#description' => t('determine the image used to look for exif and iptc metadata'),
        '#options' => $image_fields,
        '#default_value' => $default_image_value,
        '#element_validate' => array(
          '_exif_field_widget_image_field_validate',
        ),
      );
    }
    if ($instance['entity_type'] == 'file') {
      $form['image_field'] = array(
        '#type' => 'hidden',
        '#default_value' => "file",
        '#value' => "file",
      );
    }
    $form['exif_field'] = array(
      '#type' => 'select',
      '#title' => t('exif field data'),
      '#description' => t('These settings will automatically retrieve data from the image field referenced.'),
      '#options' => array_merge(array(
        'naming_convention' => 'name of the field is the exif field name',
      ), $exif_fields),
      '#default_value' => $default_exif_value,
      '#element_validate' => array(
        '_exif_field_widget_exif_field_validate',
      ),
    );
    $form['exif_field_separator'] = array(
      '#type' => 'textfield',
      '#title' => t('exif field separator'),
      '#description' => t('separator used to split values (if field definition support several values). let it empty if you do not want to split values.'),
      '#default_value' => $default_exif_separator_value,
      '#element_validate' => array(
        '_exif_field_widget_exif_field_separator_validate',
      ),
    );
  }
  return $form;
}