I'm able to add custom customer attribute called "passport".

It's working fine on Admin Side. So no issues.

For the frontend however it's not displaying on Registration page.

Below code already added InstallData.php

'used_in_forms' => ['adminhtml_customer', 'checkout_register', 'customer_account_create', 'customer_account_edit','adminhtml_checkout'],

So, for frontend, i have created Block - Widget for that Passport Field & Overriding Customer Registration Page. It's already pointing to New File.


public function _construct() {  



$_passport = $block->getLayout()->createBlock('Custom\CustomerAttribute\Block\Widget\Passport');
if ($_passport->isEnabled()):
    echo $_passport->setPassport($block->getFormData()->getPassport())->toHtml();

While running above code it's not calling <project path>\magento2\app\code\Custom\CustomerAttribute\view\frontend\templates\widget\passport.phtml file.


I got the answer & solution.


 * @return bool
public function isEnabled() {
    $attributeMetadata = $this->_getAttribute('passport');
    return $attributeMetadata ? (bool) $attributeMetadata->isVisible() : false;

Now it's displaying in frontend :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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