function fivestar_field_formatter_settings_form in Fivestar 7.2
Implements hook_field_formatter_settings_form().
File
- includes/
fivestar.field.inc, line 399 - Provides CCK integration for fivestar module.
Code
function fivestar_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
if ($display['type'] != 'fivestar_formatter_default') {
return;
}
$element['widget'] = array(
'#tree' => TRUE,
'#type' => 'fieldset',
'#title' => t('Star display options'),
'#description' => t('Choose a style for your widget.'),
'#weight' => -2,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$widgets = module_invoke_all('fivestar_widgets');
$element['widget']['fivestar_widget'] = array(
'#type' => 'radios',
'#options' => array(
'default' => t('Default'),
) + $widgets,
'#default_value' => isset($settings['widget']['fivestar_widget']) ? $settings['widget']['fivestar_widget'] : 'default',
'#attributes' => array(
'class' => array(
'fivestar-widgets',
'clearfix',
),
),
'#pre_render' => array(
'fivestar_previews_expand',
),
'#attached' => array(
'css' => array(
drupal_get_path('module', 'fivestar') . '/css/fivestar-admin.css',
),
),
);
if ($instance['widget']['type'] == 'exposed') {
$element['expose'] = array(
'#type' => 'checkbox',
'#title' => t('Allow voting on the entity.'),
'#default_value' => $settings['expose'],
'#return_value' => 1,
);
}
$element['style'] = array(
'#type' => 'select',
'#title' => t('Value to display as stars'),
'#default_value' => $settings['style'],
'#options' => array(
'average' => t('Average vote'),
'user' => t("User's vote"),
'smart' => t("User's vote if available, average otherwise"),
'dual' => t("Both user's and average vote"),
),
);
$element['text'] = array(
'#type' => 'select',
'#title' => t('Text to display under the stars'),
'#default_value' => $settings['text'],
'#options' => array(
'none' => t('No text'),
'average' => t('Average vote'),
'user' => t("User's vote"),
'smart' => t("User's vote if available, average otherwise"),
'dual' => t("Both user's and average vote"),
),
);
return $element;
}