materio-d9/web/modules/custom/materio_user/materio_user.module

58 lines
1.4 KiB
Plaintext

<?php
/**
* @file
* Contains materio_user.module.
*/
use \Drupal\Core\Form\FormStateInterface;
use \Drupal\Core\Block\BlockPluginInterface;
/**
* implements hook_form_FORM_ID_alter()
*
*/
function materio_user_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Drupal::logger('materio_user')->notice(print_r($form, true));
$form['name']['#attributes'] += array(
"v-model" => "mail",
"@keyup.enter" => "login"
);
$form['pass']['#attributes'] = array(
"v-model" => "password",
"@keyup.enter" => "login"
);
$form['actions']['submit']['#attributes'] = array(
"@click.prevent" => "login"
);
}
/**
* implements hook_block_view_BASE_BLOCK_ID_alter()
*
* https://www.drupal.org/project/drupal/issues/2626224
*/
function materio_user_block_view_user_login_block_alter(array &$build, BlockPluginInterface $block) {
$build['#pre_render'][] = '_materio_user_user_login_block_pre_render';
}
function _materio_user_user_login_block_pre_render(array $build){
$user_links = &$build['content']['user_links'];
$items = &$user_links['#items'];
// ksm($items);
$items['create_account']['#url']->mergeOptions(array(
"attributes" => array(
"@click.prevent" => "create_account"
)
));
$items['request_password']['#url']->mergeOptions(array(
'attributes' => array(
"@click.prevent" => "request_password"
)
));
return $build;
}