You are here

function fivestar_field_instance_settings_form in Fivestar 7.2

File

includes/fivestar.field.inc, line 68
Provides CCK integration for fivestar module.

Code

function fivestar_field_instance_settings_form($field, $instance) {
  $form = array();
  $widget_title = $instance['widget']['type'] == 'select' ? t('Number of options') : t('Number of stars');
  $form['stars'] = array(
    '#type' => 'select',
    '#title' => check_plain($widget_title),
    '#options' => drupal_map_assoc(range(1, 10)),
    '#default_value' => isset($instance['settings']['stars']) ? $instance['settings']['stars'] : 5,
  );
  $form['allow_clear'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow users to cancel their ratings.'),
    '#default_value' => isset($instance['settings']['allow_clear']) ? $instance['settings']['allow_clear'] : FALSE,
    '#return_value' => 1,
  );
  $form['allow_revote'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow users to re-vote on already voted content.'),
    '#default_value' => isset($instance['settings']['allow_revote']) ? $instance['settings']['allow_revote'] : TRUE,
    '#return_value' => 1,
  );
  $form['allow_ownvote'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow users to vote on their own content.'),
    '#default_value' => isset($instance['settings']['allow_ownvote']) ? $instance['settings']['allow_ownvote'] : TRUE,
    '#return_value' => 1,
  );
  $options = fivestar_get_targets($field, $instance);
  $form['target'] = array(
    '#title' => t('Voting target'),
    '#type' => 'select',
    '#default_value' => isset($instance['settings']['target']) && $instance['widget']['type'] != 'exposed' ? $instance['settings']['target'] : 'none',
    '#options' => $options,
    '#description' => t('The voting target will make the value of this field cast a vote on another node. Use node reference fields module to create advanced reviews. Use the Parent Node Target when using fivestar with comments. More information available on the <a href="http://drupal.org/handbook/modules/fivestar">Fivestar handbook page</a>.'),
    '#access' => count($options) > 1 && $instance['widget']['type'] != 'exposed',
  );
  return $form;
}