You are here

function barcode_field_instance_settings_form in Barcode 7.2

Implements hook_field_instance_settings_form().

File

./barcode.module, line 214

Code

function barcode_field_instance_settings_form($field, $instance) {
  $barcode_default_settings = barcode_get_settings();
  if ($field['settings']['encoding'] == 'QRCODE') {
    $form['barcode_height'] = array(
      '#title' => t('Height'),
      '#description' => t('Integer! in order to scan the printed barcode, the suggested height is 200'),
      '#type' => 'textfield',
      '#default_value' => isset($instance['settings']['barcode_height']) ? $instance['settings']['barcode_height'] : 200,
      '#size' => 2,
      '#required' => TRUE,
    );
  }
  else {
    $form['barcode_height'] = array(
      '#title' => t('Height'),
      '#description' => t('Integer! in order to scan the printed barcode, the suggested height is 40'),
      '#type' => 'textfield',
      '#default_value' => isset($instance['settings']['barcode_height']) ? $instance['settings']['barcode_height'] : $barcode_default_settings['height'],
      '#size' => 2,
      '#required' => TRUE,
    );
    $form['barcode_scale'] = array(
      '#title' => t('Scale'),
      '#description' => t('Float! in order to scan the printed barcode, the suggested height is 2.0'),
      '#type' => 'textfield',
      '#default_value' => isset($instance['settings']['barcode_scale']) ? $instance['settings']['barcode_scale'] : $barcode_default_settings['scale'],
      '#size' => 2,
      '#required' => TRUE,
    );
    $form['barcode_bgcolor'] = array(
      '#title' => t('Background color'),
      '#description' => t('Hex value'),
      '#type' => 'textfield',
      '#default_value' => isset($instance['settings']['barcode_bgcolor']) ? $instance['settings']['barcode_bgcolor'] : $barcode_default_settings['bgcolor'],
      '#size' => 8,
      '#required' => TRUE,
    );
    $form['barcode_barcolor'] = array(
      '#title' => t('Bar color'),
      '#description' => t('Hex value'),
      '#type' => 'textfield',
      '#default_value' => isset($instance['settings']['barcode_barcolor']) ? $instance['settings']['barcode_barcolor'] : $barcode_default_settings['barcolor'],
      '#size' => 8,
      '#required' => TRUE,
    );
  }
  $form['barcode_image_format'] = array(
    '#title' => t('Image format'),
    '#description' => t('The image format used for generated barcodes. Supported formats: png, gif, jpg.'),
    '#type' => 'select',
    '#default_value' => isset($instance['settings']['barcode_image_format']) ? $instance['settings']['barcode_image_format'] : $barcode_default_settings['image_format'],
    '#options' => array(
      'png' => 'png',
      'jpg' => 'jpg',
      'gif' => 'gif',
    ),
    '#maxlength' => 4,
    '#required' => TRUE,
  );

  // Add token module replacements fields
  if (module_exists('token')) {
    $form['tokens'] = array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => t('Placeholder tokens'),
      '#description' => t("The following placeholder tokens can be used in DEFAULT VALUE of the field. When used in DEFAULT VALUE, they will be replaced with the appropriate values."),
    );
    $token_type = array(
      'theme' => 'token_tree',
      'token_types' => array(
        $instance['entity_type'],
      ),
      'global_types' => TRUE,
      'click_insert' => TRUE,
      'recursion_limit' => 2,
    );
    $form['tokens']['help'] = array(
      '#type' => 'markup',
      '#markup' => theme('token_tree', $token_type),
    );
  }
  return $form;
}