You are here

function asin_text_process in Amazon Product Advertisement API 6

Process an individual element.

Build the form element. When creating a form using FAPI #process, note that $element['#value'] is already set.

The $fields array is in $form['#field_info'][$element['#field_name']].

1 call to asin_text_process()
asin_autocomplete_process in asin/asin.module
Process an autocomplete widget.
1 string reference to 'asin_text_process'
asin_elements in asin/asin.module
Implementation of FAPI hook_elements().

File

asin/asin.module, line 365
Defines a field type for referencing an Amazon product.

Code

function asin_text_process($element, $edit, $form_state, $form) {
  $field = $form['#field_info'][$element['#field_name']];
  $delta = $element['#delta'];
  $asin_key = $element['#columns'][0];
  if (!empty($element['#value'][$asin_key])) {
    $element['#value'][$asin_key] = trim($element['#value'][$asin_key]);
    $element['#value'][$asin_key] = amazon_convert_to_asin($element['#value'][$asin_key]);
  }
  $element[$asin_key] = array(
    '#type' => 'textfield',
    '#title' => $element['#title'],
    '#description' => $element['#description'],
    '#required' => $element['#required'],
    '#default_value' => isset($element['#value'][$asin_key]) ? $element['#value'][$asin_key] : NULL,
  );
  return $element;
}