You are here

function barcodes_field_formatter_settings_form in Barcodes 7

Implements hook_field_formatter_settings_form().

File

./barcodes.module, line 239
Contains barcodes.module.

Code

function barcodes_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $elements = array();
  $elements['#tree'] = TRUE;
  if ($display['type'] == 'barcode') {
    $generator = new BarcodeGenerator();
    $elements['type'] = [
      '#type' => 'select',
      '#title' => t('Barcode Type'),
      '#description' => t('The Barcode type.'),
      '#options' => array_combine($generator
        ->getTypes(), $generator
        ->getTypes()),
      '#default_value' => $settings['type'],
    ];
    $elements['color'] = [
      '#type' => 'textfield',
      '#title' => t('Color'),
      '#default_value' => $settings['color'],
      '#description' => t('The color code.'),
    ];
    $elements['height'] = [
      '#type' => 'textfield',
      '#title' => t('Height'),
      '#size' => 10,
      '#default_value' => $settings['height'],
      '#description' => t('The height in pixels.'),
    ];
    $elements['width'] = [
      '#type' => 'textfield',
      '#title' => t('Width'),
      '#size' => 10,
      '#default_value' => $settings['width'],
      '#description' => t('The width in pixels'),
    ];
    $elements['padding_top'] = [
      '#type' => 'textfield',
      '#title' => t('Padding-Top'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => $settings['padding_top'],
      '#description' => t('The top padding in pixels'),
    ];
    $elements['padding_right'] = [
      '#type' => 'textfield',
      '#title' => t('Padding-Right'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => $settings['padding_right'],
      '#description' => t('The right padding in pixels'),
    ];
    $elements['padding_bottom'] = [
      '#type' => 'textfield',
      '#title' => t('Padding-Bottom'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => $settings['padding_bottom'],
      '#description' => t('The bottom padding in pixels'),
    ];
    $elements['padding_left'] = [
      '#type' => 'textfield',
      '#title' => t('Padding-Left'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => $settings['padding_left'],
      '#description' => t('The left padding in pixels'),
    ];
    $elements['show_value'] = [
      '#type' => 'checkbox',
      '#title' => t('Show value'),
      '#default_value' => $settings['show_value'],
      '#description' => t('Show the actual value in addition to the barcode'),
    ];
  }
  return $elements;
}