function asin_autocomplete_validate in Amazon Product Advertisement API 7
Same name and namespace in other branches
- 6 asin/asin.module \asin_autocomplete_validate()
- 7.2 asin/asin.module \asin_autocomplete_validate()
Validate the autocomplete widget.
This corrects the value (we want just the ASIN, not the whole title).
1 string reference to 'asin_autocomplete_validate'
- asin_field_widget_form in asin/
asin.module - Implements hook_field_widget_form().
File
- asin/
asin.module, line 319 - Defines a field type for referencing an Amazon product.
Code
function asin_autocomplete_validate($element, &$form_state) {
$value = $element['#value'];
$asin = NULL;
if (preg_match('!.*\\[asin\\:([a-zA-Z0-9]*)\\]!', $value, $matches)) {
$asin = $matches[1];
}
else {
$asin = $value;
}
form_set_value($element, $asin, $form_state);
}