function entityreference_field_formatter_settings_form in Entity reference 7
Implements hook_field_formatter_settings_form().
File
- ./
entityreference.module, line 1196 - Entityreference primary module file.
Code
function entityreference_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$field_type_settings = entityreference_field_type_settings($field);
$element = array();
if ($display['type'] == 'entityreference_label') {
$element['bypass_access'] = array(
'#title' => t('Show entity labels regardless of user access'),
'#description' => t("All entities in the field will be shown, without checking them for access. If the 'Link' setting is also enabled, an entity which the user does not have access to view will show without a link."),
'#type' => 'checkbox',
'#default_value' => $settings['bypass_access'],
);
$element['link'] = array(
'#title' => t('Link label to the referenced entity'),
'#type' => 'checkbox',
'#default_value' => $settings['link'],
);
}
if ($display['type'] == 'entityreference_entity_view') {
$entity_info = entity_get_info($field_type_settings['entity_type']);
$options = array(
'default' => t('Default'),
);
if (!empty($entity_info['view modes'])) {
foreach ($entity_info['view modes'] as $view_mode => $view_mode_settings) {
$options[$view_mode] = $view_mode_settings['label'];
}
}
$element['view_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => t('View mode'),
'#default_value' => $settings['view_mode'],
'#access' => count($options) > 1,
);
$element['links'] = array(
'#type' => 'checkbox',
'#title' => t('Show links'),
'#default_value' => $settings['links'],
);
$element['use_content_language'] = array(
'#type' => 'checkbox',
'#title' => t('Use current content language'),
'#default_value' => $settings['use_content_language'],
);
$element['hide_title'] = array(
'#type' => 'checkbox',
'#title' => t('Hide title'),
'#default_value' => $settings['hide_title'],
);
}
return $element;
}