function makemeeting_field_formatter_view in Make Meeting Scheduler 7.2
Implements hook_field_formatter_view().
Build a renderable array for a field value.
Parameters
$entity_type: The type of $entity.
$entity: The entity being displayed.
$field: The field structure.
$instance: The field instance.
$langcode: The language associated with $items.
$items: Array of values for this field.
$display: The display settings to use, as found in the 'display' entry of instance definitions. The array notably contains the following keys and values;
- type: The name of the formatter to use.
- settings: The array of formatter settings.
Return value
array A renderable array for the $items, as an array of child elements keyed
File
- ./
makemeeting.field.inc, line 430 - This file is mostly about the field configuration.
Code
function makemeeting_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$content = array();
foreach ($items as $delta => $item) {
list($entity_id) = entity_extract_ids($entity_type, $entity);
$instance += array(
'entity_id' => $entity_id,
'language' => $langcode,
'delta' => $delta,
);
// Define answers hidden status here as we have $field variable available
$item['is_hidden'] = (bool) $item['hidden'];
if ($item['is_hidden']) {
$access = field_access('edit', $field, $entity_type, $entity);
if ($entity_type == 'node') {
$access = $access && node_access('update', $entity);
}
elseif (module_exists('entity')) {
$access = $access && entity_access('edit', $entity_type, $entity);
}
$item['is_hidden'] = $item['is_hidden'] && !$access;
}
if (isset($instance['entity_id'])) {
$content[] = drupal_get_form('makemeeting_answers_form_' . $instance['entity_id'], $item, $instance);
}
}
return $content;
}