I'm trying to add a field in the "new customer" form, so i would like to put something into customer_account_create.xml layout, precisely in the block

<block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml">

so, after

<container name="customer.form.register.fields.before" as="form_fields_before" label="Form Fields Before" htmlTag="div" htmlClass="customer-form-before"/>

but before the "name widget" created runtime as a block in register.phtml

<legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Personal Information') ?></span></legend><br>
<?php echo $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Name')->setObject($block->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>

but i can't manage to do it

i tried on my custom customer_account_create.xml, under my modules view/frontend/layout directory, putting

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="customer_form_register">
            <block class="Magento\Framework\View\Element\Template" name="smtn-be4-name"  as="before-name" template="Vendor_Module::customTemplate.phtml" after="form_fields_before"/>

but it doesnt appear (lets say i created customTemplate.phtml under my module's view/frontend/templates directory, which prints something)

any ideas/help? thanks in advance


1 Answer 1


okay, there's no way to refer a block which is created runtime like the widgets for customer data (name etc .) this is -quite obviously- because widgets are rendered AFTER the blocks defined in the layout xml

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.