function cas_form_user_login_form_alter in CAS 8
Same name and namespace in other branches
- 2.x cas.module \cas_form_user_login_form_alter()
Implements hook_form_FORM_ID_alter().
Modify the user login form.
File
- ./
cas.module, line 217 - Provides CAS authentication for Drupal.
Code
function cas_form_user_login_form_alter(&$form, FormStateInterface $form_state) {
$config = Drupal::config('cas.settings');
// Cached form must be busted if we alter CAS settings.
$form['#cache']['tags'] = array_merge($form['#cache']['tags'], $config
->getCacheTags());
// Add a link to login via CAS on the user login form.
$enabled = $config
->get('login_link_enabled');
if ($enabled) {
$url = new Url('cas.login', [], [
'attributes' => [
'class' => [
'cas-login-link',
],
],
]);
$form['cas_login_link'] = [
'#type' => 'link',
'#url' => $url,
'#title' => $config
->get('login_link_label'),
'#weight' => -1,
];
}
$form['#validate'][] = '_cas_user_login_validate';
}