0

I have included the register.phtml file in another .phtml file using the following code:

<?php echo $this->getLayout()->createBlock("Magento\Customer\Block\Form\Register")->setTemplate("Magento_Customer::form/register.phtml")->toHtml(); ?>

This code is used to display the registration form as a popup. Additionally, I have created an customer_account_create.xml file to enable the display of address fields on the registration form. When I navigate to $baseUrl/customer/account/create/, the address fields are displayed correctly. However, when I open the popup that calls the register.phtml file, the address fields are not displayed.

The path where I have called the register.phtml file is: app/design/frontend/Smartwave/porto_child/Smartwave_Porto/templates/html/login.phtml.

I also tried using the following approach: <?php $this->setShowAddressFields(true) ?> But I encountered the following error: Error: Call to a member function getFrontendLabel() on null.

1 Answer 1

0

The error "Call to a member function getFrontendLabel()" typically occurs when Magento tries to access the frontend label of an attribute that does not exist or is not properly initialized. This often happens in the context of rendering forms.

When you enable the address fields on the registration page using $this->setShowAddressFields(true), Magento attempts to render the address fields, but it seems some attribute configurations might be missing or improperly set.

Here's how you can troubleshoot and fix this issue:

1. Check Address Attributes Configuration

Ensure that all necessary address attributes are properly configured in the database. These attributes should have frontend labels set.

Run the following SQL queries to check the address attributes:

SELECT attribute_id, attribute_code, frontend_label FROM eav_attribute WHERE entity_type_id = (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'customer_address');

Ensure that all essential attributes like firstname, lastname, street, city, postcode, telephone, etc., have frontend labels.

2. Check Custom Theme/Module Overrides

If you are using a custom theme or module that overrides the customer registration template or block, ensure that the overrides are correctly implemented.

3. Review the Registration Template

Ensure the registration template properly initializes and renders the address fields. Locate the template file responsible for the registration form, usually found at:

app/design/frontend/[Vendor]/[theme]/Magento_Customer/templates/form/register.phtml

If you have overridden this template, make sure it properly calls the address block.

1
  • Hi! I am sure frontend labels exist and I have overridden the file correctly as I have done some other changes like name etc, Plus when I create an account via popup the account is created. p.s another issue I am facing is I am using google address suggestions api which also only work on signup page but not when I open the popup TIA Commented May 27 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.