You are here

function amazon_test_form_validate in Amazon Product Advertisement API 7

Same name and namespace in other branches
  1. 7.2 amazon.admin.inc \amazon_test_form_validate()

File

./amazon.admin.inc, line 168
Amazon Admin pages.

Code

function amazon_test_form_validate($form, &$form_state) {

  // Normalize input and look up
  $asin = amazon_convert_to_asin($form_state['values']['asin']);
  $items = amazon_item_lookup_from_web(array(
    $asin,
  ), $form_state['values']['locale']);
  if (!empty($items) && is_array($items)) {
    $form_state['amazon_item'] = array_pop($items);
  }
  else {
    form_set_error('asin', t("%input is no valid ASIN or EAN. Please check the !link for messages.", array(
      '%input' => $form_state['values']['asin'],
      '!link' => l(t("error log"), 'admin/reports/dblog'),
    )));
  }
}