function blockreference_field_widget_form in Block reference 7
Same name and namespace in other branches
- 7.2 blockreference.field.inc \blockreference_field_widget_form()
Implements hook_field_widget_form().
File
- ./
blockreference.module, line 361 - Defines a field type for referencing a block from a node.
Code
function blockreference_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
switch ($instance['widget']['type']) {
case 'blockreference_autocomplete':
$current_bid = isset($items[$delta]['bid']) ? $items[$delta]['bid'] : NULL;
$element += array(
'#type' => 'textfield',
'#default_value' => $current_bid,
'#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $instance['entity_type'] . '/' . $field['field_name'] . '/' . (int) $current_bid,
'#size' => $instance['widget']['settings']['size'],
'#element_validate' => array(
'blockreference_autocomplete_validate',
),
'#value_callback' => 'blockreference_autocomplete_value',
);
$element = array(
'bid' => $element,
);
break;
case 'blockreference_select_sort':
$element = array(
'#type' => 'blockreference_select_sort',
'#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
);
break;
}
return $element;
}