You are here

public function RoleLoginPageSettingsEdit::submitForm in Multiple role login pages 8

Parameters

array $form:

FormStateInterface $form_state:

Overrides FormInterface::submitForm

File

src/Form/RoleLoginPageSettingsEdit.php, line 190
�* �* Contains \Drupal\role_login_page\Form\RoleLoginPageSettingsEdit. �

Class

RoleLoginPageSettingsEdit
Edit login page form.

Namespace

Drupal\role_login_page\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $rl_id = $this->rlid;
  $url = trim($form_state
    ->getValue([
    'loginmenu_url',
  ]));
  $replacements = [
    '!',
    '*',
    "(",
    ")",
    ";",
    ":",
    "@",
    "+",
    "\$",
    ",",
    "[",
    "]",
    " ",
  ];
  $url = str_replace($replacements, '-', $url);
  $username_label = trim($form_state
    ->getValue([
    'username_label',
  ]));
  $password_label = trim($form_state
    ->getValue([
    'password_label',
  ]));
  $submit_text = trim($form_state
    ->getValue([
    'submit_text',
  ]));
  $page_title = trim($form_state
    ->getValue([
    'page_title',
  ]));
  $redirect_path = trim($form_state
    ->getValue([
    'redirect_path',
  ]));
  $role_mismatch_error_text = trim($form_state
    ->getValue([
    'role_mismatch_error_text',
  ]));
  $invalid_credentials_error_text = trim($form_state
    ->getValue([
    'invalid_credentials_error_text',
  ]));
  $parent_class = $form_state
    ->getValue([
    'parent_class',
  ]);
  $roles = $form_state
    ->getValue([
    'roles',
  ]);
  $roles = implode(',', $roles);
  $this->connection
    ->update('role_login_page_settings')
    ->fields([
    "url" => $url,
    "username_label" => $username_label,
    "password_label" => $password_label,
    "submit_text" => $submit_text,
    "page_title" => $page_title,
    "parent_class" => $parent_class,
    "redirect_path" => $redirect_path,
    "role_mismatch_error_text" => $role_mismatch_error_text,
    "invalid_credentials_error_text" => $invalid_credentials_error_text,
    "roles" => $roles,
  ])
    ->condition('rl_id', $rl_id)
    ->execute();
  _role_login_page_settings_cache_clear($url, 'update');
}