You are here

function starrating_field_formatter_settings_form in Star Rating 7.2

Implements hook_field_formatter_settings_form().

File

./starrating.module, line 64
Provides star rating field, formatter and widget using Field API. star rating field is based on integer value and convert it to the HTML code that displays series of icons. The formatter supports not only star rating field type but also…

Code

function starrating_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();
  $element['fill_blank'] = array(
    '#type' => 'checkbox',
    '#title' => t('Fill with blank icons'),
    '#default_value' => $settings['fill_blank'],
  );
  $element['icon_type'] = array(
    '#type' => 'select',
    '#title' => t('Icon type'),
    '#options' => array(
      'star' => t('Star'),
      'star-line' => t('Star (outline)'),
      'check' => t('Check'),
      'heart' => t('Heart'),
      'dollar' => t('Dollar'),
      'smiley' => t('Smiley'),
      'food' => t('Food'),
      'coffee' => t('Coffee'),
      'movie' => t('Movie'),
      'music' => t('Music'),
      'human' => t('Human'),
      'thumbs-up' => t('Thumbs Up'),
      'car' => t('Car'),
      'airplane' => t('Airplane'),
      'fire' => t('Fire'),
      'drupalicon' => t('Drupalicon'),
      'custom' => t('Custom'),
    ),
    '#default_value' => $settings['icon_type'],
    '#prefix' => '<img src="' . base_path() . drupal_get_path('module', 'starrating') . '/icons/sample.png" />',
  );
  $element['icon_color'] = array(
    '#type' => 'select',
    '#title' => t('Icon color'),
    '#options' => array(
      1 => '1',
      2 => '2',
      3 => '3',
      4 => '4',
      5 => '5',
      6 => '6',
      7 => '7',
      8 => '8',
    ),
    '#default_value' => $settings['icon_color'],
  );
  return $element;
}