materio_user.module 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @file
  4. * Contains materio_user.module.
  5. */
  6. use \Drupal\Core\Form\FormStateInterface;
  7. use \Drupal\Core\Block\BlockPluginInterface;
  8. /**
  9. * implements hook_form_FORM_ID_alter()
  10. *
  11. */
  12. function materio_user_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  13. // Drupal::logger('materio_user')->notice(print_r($form, true));
  14. $form['name']['#attributes'] += array(
  15. "v-model" => "mail",
  16. "@keyup.enter" => "login"
  17. );
  18. $form['pass']['#attributes'] = array(
  19. "v-model" => "password",
  20. "@keyup.enter" => "login"
  21. );
  22. $form['actions']['submit']['#attributes'] = array(
  23. "@click.prevent" => "login"
  24. );
  25. }
  26. /**
  27. * implements hook_block_view_BASE_BLOCK_ID_alter()
  28. *
  29. * https://www.drupal.org/project/drupal/issues/2626224
  30. */
  31. function materio_user_block_view_user_login_block_alter(array &$build, BlockPluginInterface $block) {
  32. $build['#pre_render'][] = '_materio_user_user_login_block_pre_render';
  33. }
  34. function _materio_user_user_login_block_pre_render(array $build){
  35. $user_links = &$build['content']['user_links'];
  36. $items = &$user_links['#items'];
  37. // ksm($items);
  38. $items['create_account']['#url']->mergeOptions(array(
  39. "attributes" => array(
  40. "@click.prevent" => "create_account"
  41. )
  42. ));
  43. $items['request_password']['#url']->mergeOptions(array(
  44. 'attributes' => array(
  45. "@click.prevent" => "request_password"
  46. )
  47. ));
  48. return $build;
  49. }