I am using the following code to make the login form appear in a popup form. It all works great but I have 2 issues:

1) On login success, the popup does not close or refresh the page to show that the user is now logged in

2) On failed login, the error message shows in the popup (Which is great) but if a second error occurs, e.g. wrong password again, the original messages stays so you have 2 errors showing. I would like to only see the most recent one

Any help would be much appreciated!

  $url = Url::fromRoute('user.login');
    $link_options = array(
      'attributes' => array(
        'class' => array(
          'use-ajax',
          'login-popup-form',
        ),
        'data-dialog-type' => 'modal',
      ),
    );
    $url->setOptions($link_options);
    $link = Link::fromTextAndUrl(t('<i class="fa fa-angle-right">‌</i> Log in'), $url)->toString();

Comments

cjsmith87 created an issue. See original summary.

marceldeb’s picture

Hi,

At this moment the module does not support modals. This is a feature i would like to add too as other use cases also need this. For example when deleting a node using a modal, the original delete button redirects to a new page in stead of the modal.

So 1) Feature request - When opening forms in a modal, the links / actions should be rewritten to support the modal as well. This is part of the full ajax experience this module should offer for forms. Let me work on a patch for that.

And 2) I think this is fixed in the 8.x.1.1-Development branch. Can you try that one?

marceldeb’s picture

Assigned: Unassigned » marceldeb
marceldeb’s picture

Status: Active » Fixed

I just worked on 1 & 2

1) On login success, the popup does not close or refresh the page to show that the user is now logged in
This is default Drupal behaviour. Drupal does not show a message when you log in. You might want to change that using a community module or a custom one:

/**
 * Implementation of hook_user_login()
 */
function my_custom_module_login_user_login(\Drupal\user\UserInterface $account) {
     \Drupal::messenger()->addStatus(t('You are logged in.'));
}

2) the error message shows in the popup (Which is great) but if a second error occurs, e.g. wrong password again, the original messages stays so you have 2 errors showing. I would like to only see the most recent one.
Answer: I just tested this with a clean Drupal environment and it should work with the latest beta / dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.