function getdirections_fields_field_formatter_settings_form in Get Directions 7.3
Implements hook_field_formatter_settings_form(). Returns form elements for a formatter's settings.
Parameters
$field: The field structure being configured.
$instance: The instance structure being configured.
$view_mode: The view mode being configured.
$form: The (entire) configuration form array, which will usually have no use here.
$form_state: The form state of the (entire) configuration form.
Return value
The form elements for the formatter settings.
File
- modules/
getdirections_fields/ getdirections_fields.module, line 309 - Provides Field module integration for Getdirections
Code
function getdirections_fields_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
drupal_add_js(GETDIRECTIONS_FIELDS_PATH . '/js/getdirections_fields_formatter.js');
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element = array();
switch ($display['type']) {
case 'getdirections_fields_default':
$default_settings = getdirections_fields_field_formatter_settings();
if (empty($settings)) {
$settings = $default_settings;
}
else {
$settings = getdirections_adjust_vars($default_settings, $settings);
}
// default settings
$element['default'] = array(
'#type' => 'fieldset',
'#title' => t('Get directions map settings'),
// This will store all the defaults in one variable.
'#tree' => TRUE,
);
$element['default'] += getdirections_default_settings($settings['default'], '');
$element['direction_opt'] = array(
'#type' => 'select',
'#title' => t('Direction of location'),
'#default_value' => $settings['direction_opt'],
'#options' => $settings['direction_options'],
);
// misc
$element['misc'] = array(
'#type' => 'fieldset',
'#title' => t('Other settings'),
// This will store all the defaults in one variable.
'#tree' => TRUE,
);
$element['misc'] += getdirections_misc_settings($settings['misc'], FALSE, FALSE);
break;
case 'getdirections_fields_link':
$element['text'] = array(
'#type' => 'textfield',
'#title' => t('Default text'),
'#description' => t('The text to use if no other option is available.'),
'#default_value' => $settings['text'],
'#size' => 25,
);
$element['text_opt'] = array(
'#type' => 'select',
'#title' => t('Display format'),
'#default_value' => $settings['text_opt'],
'#options' => $settings['text_options'],
);
$element['direction_opt'] = array(
'#type' => 'select',
'#title' => t('Direction'),
'#default_value' => $settings['direction_opt'],
'#options' => $settings['direction_options'],
);
break;
}
return $element;
}