0

I cannot figure out how I can add placeholder for some custom attribute on create account page.

In this file: view/frontend/templates/customer/form/register.phtml i see some code which output html for my attribute:

    <?php $customerAttributes = $block->getChildBlock('customer_form_user_attributes');?>
    <?php if ($customerAttributes): ?>
        <?php $customerAttributes->setObject($block->getFormData())
            ->setEntityType('customer')
            ->setShowContainer(false);?>
        <?php $block->restoreSessionData($customerAttributes->getMetadataForm());?>
        <?= $customerAttributes->toHtml() ?>
    <?php endif;?>

But how to add the one I need placeholder for my custom attribute I cannot think of and track how this can be done.

Please, help me!

1 Answer 1

0

Show customer attributes in the customer registration form For showing customer attributes on the registration page, we need to do the following steps:

First, we will add our phtml files to ‘form.additional.info’ reference name using

Module/CustomerAttribute/view/frontend/layout/customer_account_create.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     layout="1column"
     xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
       <referenceContainer name="form.additional.info">
           <block class="Magento\Framework\View\Element\Template"
                  name="phone_number"
                  template="Magenest_CustomerAttribute::extra_field.phtml"/>
       </referenceContainer>
   </body>
</page>

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.