Create block 'customer/form_register' on account login page

Create block 'customer/form_register' on account login page

October 1, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Create block 'customer/form_register' on account login page

Displaying Registration Fields on Account Login Page in Magento

As an experienced Magento developer, I often receive queries from merchants looking to customize their storefront layouts. One common request is to display the customer registration form directly on the account login page. In this post, I’ll guide you through a step-by-step approach to achieve this while avoiding the pitfalls of the incorrect techniques described in your question.

Understanding Magento’s Layout XML

Magento uses layout XML files to determine how content is rendered on pages. The customer_account_login.xml file under app/design/frontend/<vendor>/<theme>/layout is responsible for the account login page. To add new blocks, we need to modify this file correctly.

Correct Approach: Adding the Registration Form Block

To display the registration form above the login form, you need to add a new block type and reference it before the customer_form_login block in your XML layout:

<reference name="content">
    <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml"/>
    <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
</reference>

Notice the change in order: I placed the customer_form_register block before the customer_form_login. This ensures that the registration form is rendered first.

Correcting the PHP Code

You mentioned that this PHP code didn’t work:

<?php echo $this->getLayout()->createBlock('customer/form_register')->toHtml() ?>

The issue here lies in the context where you’re trying to use this code. This type of inline block creation doesn’t work within the page layout XML file itself.

Using Layout Handles Correctly

To add a block dynamically using PHP, you should create a new block and set it to be rendered through a specific handle. Here’s how you do that:

$registerForm = $this->getLayout()->createBlock('customer/form_register');
$this->getLayout()->getUpdate()->addHandle('customer_account_login');
$this->getLayout()->getUpdate()->addHandle('customer_form_register', 'customer_form_register.phtml');

// Render the block
echo $registerForm->toHtml();

In this code, I’ve added two handles: customer_account_login to ensure we’re modifying the correct page layout, and a custom handle for our registration form with the appropriate template.

Conclusion

Displaying both login and registration forms on a single page in Magento requires careful handling of the layout XML and PHP block creation. By following the approach outlined above, you should be able to achieve your desired layout without any conflicts or rendering issues.

Remember that Magento’s layout system is powerful but can be complex if not handled properly. Always ensure you understand the context of where you’re making changes to avoid unexpected results.

For more advanced customizations like these, I recommend checking out our comprehensive Magento development guides on Laravel Company. We regularly publish articles covering best practices and step-by-step tutorials for various Magento features.

Themes Orders Customers

Our network