You are here

public function BaseRatingForm::getFormId in Votingapi Widgets 8

Returns a unique string identifying the form.

The returned ID should be a unique string that can be a valid PHP function name, since it's used in hook implementation names such as hook_form_FORM_ID_alter().

Return value

string The unique string identifying the form.

Overrides EntityForm::getFormId

File

src/Form/BaseRatingForm.php, line 51

Class

BaseRatingForm
Form controller for Campaign edit forms.

Namespace

Drupal\votingapi_widgets\Form

Code

public function getFormId() {
  $form_id = parent::getFormId();
  $entity = $this
    ->getEntity();
  $voted_entity_type = $entity
    ->getVotedEntityType();
  $voted_entity_id = $entity
    ->getVotedEntityId();
  $voted_entity = $this->entityTypeManager
    ->getStorage($voted_entity_type)
    ->load($voted_entity_id);
  $additional_form_id_parts = [];
  $additional_form_id_parts[] = $voted_entity
    ->getEntityTypeId();
  $additional_form_id_parts[] = $voted_entity
    ->bundle();
  $additional_form_id_parts[] = $voted_entity
    ->id();
  $additional_form_id_parts[] = $entity
    ->bundle();
  $additional_form_id_parts[] = $entity->field_name->value;
  $form_id = implode('_', $additional_form_id_parts) . '__' . $form_id;
  return $form_id;
}