You are here

public function EmailRegistrationLogin::buildPaneForm in Email Registration 8

Builds the pane form.

Parameters

array $pane_form: The pane form, containing the following basic properties:

  • #parents: Identifies the position of the pane form in the overall parent form, and identifies the location where the field values are placed within $form_state->getValues().

\Drupal\Core\Form\FormStateInterface $form_state: The form state of the parent form.

array $complete_form: The complete form structure.

Overrides Login::buildPaneForm

File

src/Plugin/Commerce/CheckoutPane/EmailRegistrationLogin.php, line 80

Class

EmailRegistrationLogin
Provides the email registration login pane.

Namespace

Drupal\email_registration\Plugin\Commerce\CheckoutPane

Code

public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
  $pane_form = parent::buildPaneForm($pane_form, $form_state, $complete_form);
  $login_with_username = $this->config
    ->get('login_with_username');
  $pane_form['returning_customer']['name']['#title'] = $login_with_username ? $this
    ->t('Email address or username') : $this
    ->t('Email address');
  $pane_form['returning_customer']['name']['#description'] = $login_with_username ? $this
    ->t('Enter your email address or username.') : $this
    ->t('Enter your email address.');
  $pane_form['returning_customer']['name']['#element_validate'][] = 'email_registration_user_login_validate';
  $pane_form['returning_customer']['name']['#type'] = $login_with_username ? 'textfield' : 'email';
  $pane_form['returning_customer']['name']['#maxlength'] = Email::EMAIL_MAX_LENGTH;
  $pane_form['returning_customer']['password']['#description'] = $this
    ->t('Enter the password that accompanies your email address.');
  $complete_form['#cache']['tags'][] = 'config:email_registration.settings';
  $pane_form['register']['name']['#type'] = 'value';
  $pane_form['register']['name']['#value'] = 'email_registration_' . user_password();
  $pane_form['register']['mail']['#title'] = $this
    ->t('Email');
  return $pane_form;
}