You are here

function barcodefield_process in Barcode 6.2

Process an individual element.

1 string reference to 'barcodefield_process'
barcodefield_elements in ./barcodefield.module
Implementation of FAPI hook_elements().

File

./barcodefield.module, line 155

Code

function barcodefield_process($element, $edit, $form_state, $form) {
  $field = $form['#field_info'][$element['#field_name']];
  $field_key = $element['#columns'][0];

  // here $field_key is barcode
  $delta = $element['#delta'];
  if ($field['title'] != 'none' && $field['title'] != 'value') {
    $element['title'] = array(
      '#type' => 'textfield',
      '#maxlength' => '20',
      '#size' => '20',
      '#title' => t('Title'),
      '#required' => $field['title'] == 'required' && !empty($element['#value'][$field_key]) ? TRUE : FALSE,
      '#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL,
    );
  }
  module_load_include('inc', 'barcode', 'includes/barcode.plugins');
  $maxlength = barcode_plugin_max_length(variable_get('barcode_encoding', 'EAN-13'));
  $element[$field_key] = array(
    '#type' => 'textfield',
    '#maxlength' => $maxlength,
    '#size' => '20',
    '#title' => t($field['widget']['label']),
    '#description' => t($field['widget']['description']),
    '#required' => $element['#required'],
    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
  );
  return $element;
}