You are here

function fivestar_form_field_ui_field_edit_form_alter in Fivestar 8

Same name and namespace in other branches
  1. 7.2 includes/fivestar.field.inc \fivestar_form_field_ui_field_edit_form_alter()

Implements hook_form_FORM_ID_alter().

File

./fivestar.module, line 175
A simple n-star voting widget, usable in other forms.

Code

function fivestar_form_field_ui_field_edit_form_alter(&$form, $form_state) {

  /** @var Drupal\field\FieldStorageConfigInterface $field */
  $field = $form['#field'];
  if ($field
    ->getType() == 'fivestar') {

    // Multiple values is not supported with Fivestar.
    $form['field']['cardinality']['#access'] = FALSE;
    $form['field']['cardinality']['#value'] = 1;

    // Setting "default value" here is confusing and for all practical purposes
    // meaningless with existing widgets provided by fivestar (and anything else
    // available in contrib).
    $form['instance']['default_value_widget']['#access'] = FALSE;
  }
}