Jump to content

Login and Register form side by side


trakinage

Recommended Posts

  • 1 year later...

u need configure the AuthController.php, remove the if statment in initContent(). Should look like this

    public function initContent()
    {
        $should_redirect = false;

        
        $login_form = $this->makeLoginForm()->fillWith(
            Tools::getAllValues()
        );

        $register_form = $this
                ->makeCustomerForm()
                ->setGuestAllowed(false)
                ->fillWith(Tools::getAllValues());

        if (Tools::isSubmit('submitLogin')) {
            if ($login_form->submit()) {
                $should_redirect = true;
            }
        }

        if (Tools::isSubmit('submitCreate')) {
            $hookResult = array_reduce(
                Hook::exec('actionSubmitAccountBefore', array(), null, true),
                function ($carry, $item) {
                    return $carry && $item;
                },
                true
            );
            if ($hookResult && $register_form->submit()) {
                $should_redirect = true;
            }
        }

        $this->context->smarty->assign([
            'login_form' => $login_form->getProxy(),
            'register_form' => $register_form->getProxy(),
                'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop'),
        ]);
        $this->setTemplate('customer/authentication');
        

and then add to authenthication.tpl this line and you can style this like u want

{render file='customer/_partials/customer-form.tpl' ui=$register_form}

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...
On 2/10/2020 at 5:51 PM, silvervian said:

u need configure the AuthController.php, remove the if statment in initContent(). Should look like this


    public function initContent()
    {
        $should_redirect = false;

        
        $login_form = $this->makeLoginForm()->fillWith(
            Tools::getAllValues()
        );

        $register_form = $this
                ->makeCustomerForm()
                ->setGuestAllowed(false)
                ->fillWith(Tools::getAllValues());

        if (Tools::isSubmit('submitLogin')) {
            if ($login_form->submit()) {
                $should_redirect = true;
            }
        }

        if (Tools::isSubmit('submitCreate')) {
            $hookResult = array_reduce(
                Hook::exec('actionSubmitAccountBefore', array(), null, true),
                function ($carry, $item) {
                    return $carry && $item;
                },
                true
            );
            if ($hookResult && $register_form->submit()) {
                $should_redirect = true;
            }
        }

        $this->context->smarty->assign([
            'login_form' => $login_form->getProxy(),
            'register_form' => $register_form->getProxy(),
                'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop'),
        ]);
        $this->setTemplate('customer/authentication');
        

and then add to authenthication.tpl this line and you can style this like u want


{render file='customer/_partials/customer-form.tpl' ui=$register_form}

 

Hi,

this adds the customer registration form along on login page, please can you tell me how "Create an account button" can be added on the left as same as in the screenshot above?

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...