0

I have displayed additional fields when registering a new customer.

  • company name
  • address
  • mobile phone

I miss the "company's registration number" field

How can I create this field and display it in the registration form and client panel?

1 Answer 1

1

Copy core file vendor\magento\module-customer\view\frontend\templates\form\register.phtml in your current active theme

For eg.

app/design/frontend/{YOUR_PACKAGE}/{YOUR_THEME}/Magento_Customer/templates/form/register.phtml

After add below code in above file after company field (after line number 63 or 64)

<div class="field company_registration_number required">
    <label for="company_registration_number" class="label"><span><?php /* @escapeNotVerified */ echo __("Company's registration number") ?></span></label>
    <div class="control">
        <input type="text" name="company_registration_number" value="<?php echo $block->escapeHtml($block->getFormData()->getCompanyRegistrationNumber()) ?>" title="<?php /* @escapeNotVerified */ echo __("Company's registration number") ?>" id="company_registration_number" class="input-text required-entry" data-validate="{required:true}">
    </div>
</div>

After run below commands

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean

Note: But first create customer address attribute

Company's registration number

Here I have used attribute code company_registration_number. If you are already created then add your attribute code in above code.

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.