function button_field_field_formatter_view in Button Field 7
Implements hook_field_formatter_view().
File
- ./
button_field.module, line 128 - Defines a field, widget and formatter for the button field type.
Code
function button_field_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$ids = entity_extract_ids($entity_type, $entity);
$entity_id = $ids[0];
// Build the field element.
$delta = isset($display['views_row_id']) ? $display['views_row_id'] : 0;
$id = _button_field_build_id($field, 'view', $delta, $langcode);
$element = _button_field_build_element($id, $field, $instance, $entity_type, $entity);
$form_state = array(
'build_info' => array(
'args' => array(
&$entity,
),
),
'#entity_type' => $entity_type,
'#' . $entity_type => &$entity,
'#field' => &$field,
'#instance' => &$instance,
'#element' => $element,
);
$form = drupal_build_form('button_field_dummy_form', $form_state);
$element = ajax_process_form($element, $form_state);
$form[$field['field_name']] = $element;
$form_state['#element'] = $element;
form_set_cache($form['#build_id'], $form, $form_state);
$form = _button_field_get_dummy_form($entity_type, $entity, $field, $instance, $element);
return $form;
}