You are here

function commerce_file_field_settings_form in Commerce File 7

Implements hook_field_settings_form().

File

includes/commerce_file.field.inc, line 97
Implement an commerce_file field, based on the file module's file field.

Code

function commerce_file_field_settings_form($field, $instance, $has_data) {
  $form = array();
  $defaults = field_info_field_settings($field['type']);
  $settings = array_merge($defaults, $field['settings']);
  $scheme_options = _commerce_file_get_private_stream_wrappers_options();
  if (!empty($scheme_options)) {
    $form['uri_scheme'] = array(
      '#type' => 'radios',
      '#title' => t('Private upload destination'),
      '#options' => $scheme_options,
      '#default_value' => $settings['uri_scheme'],
      '#disabled' => $has_data,
    );
  }
  else {
    drupal_set_message(t('Commerce File requires a private file scheme. Visit <a href="!url">admin/config/media/file-system</a> to set your private file path. Optionally, a private scheme other than Drupal\'s may be implemented.', array(
      '!url' => url('admin/config/media/file-system'),
    )), 'error');
  }
  return $form;
}