function asin_field_widget_form in Amazon Product Advertisement API 7
Same name and namespace in other branches
- 7.2 asin/asin.module \asin_field_widget_form()
Implements hook_field_widget_form().
File
- asin/
asin.module, line 236 - Defines a field type for referencing an Amazon product.
Code
function asin_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $base) {
$element = $base;
$element['asin'] = $base + array(
'#type' => 'textfield',
'#default_value' => !empty($items[$delta]['asin']) ? $items[$delta]['asin'] : '',
);
switch ($instance['widget']['type']) {
case 'asin_text':
$element['asin']['#size'] = 25;
$element['asin']['#element_validate'] = array(
'asin_field_widget_element_validate',
);
break;
case 'asin_autocomplete':
$element['asin']['#autocomplete_path'] = 'asin/autocomplete/' . $instance['entity_type'] . '/' . $instance['bundle'] . '/' . $field['field_name'];
$element['asin']['#value_callback'] = 'asin_autocomplete_value';
$element['asin']['#maxlength'] = 256;
$element['asin']['#element_validate'][] = 'asin_autocomplete_validate';
break;
}
$form_state['langcode'] = $langcode;
return $element;
}