You are here

public function SubscriptionForm::getFormId in Mailing List 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/SubscriptionForm.php, line 171

Class

SubscriptionForm
Form controller for mailing list subscription form.

Namespace

Drupal\mailing_list\Form

Code

public function getFormId() {
  if (empty($this->customId)) {
    return parent::getFormId();
  }
  $form_id = 'mailing_list_subscription_' . $this->entity
    ->bundle() . '_' . $this->customId;
  if ($this->operation != 'default') {
    $form_id = $form_id . '_' . $this->operation;
  }

  // Sanitize id. Removes prefixed, tailing and double "_".
  $form_id = trim(preg_replace('/_+/', '_', $form_id), '_');
  return $form_id . '_form';
}