Magento 2 – How to add a placeholder in company field of customer address edit form(edit.phtml)?

All we need is an easy explanation of the problem, so here it is.

I have been trying to add a placeholder in the company field of customer address edit form(edit.phtml) in Magento 2. Any suggestion or advice where should I be looking I looked into the block of 'Magento\Customer\Block\Widget\Company' but couldn’t find anything helpful


getLayout()->createBlock(‘Magento\Customer\Block\Widget\Company’) ?>

<?php if ($_company->isEnabled()): ?>
    <?= $_company->setCompany($block->getAddress()->getCompany())->toHtml() ?>
<?php endif ?>

enter image description here

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Open vendor/magento/module-customer/view/frontend/templates/widget/company.phtml file and add placeholder attribute in input tag.

 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

/** @var \Magento\Customer\Block\Widget\Company $block */
<div class="field company <?= $block->isRequired() ? 'required' : '' ?>">
    <label for="company" class="label">
            <?= $block->escapeHtml(__('Company')) ?>
    <div class="control">
            $_validationClass = $block->escapeHtmlAttr(
        <input type="text"
               id="company" placeholder="Company Placeholder"
               value="<?= $block->escapeHtmlAttr($block->getCompany()) ?>"
               title="<?= $block->escapeHtmlAttr(__('Company')) ?>"
               class="input-text <?= $_validationClass ?: '' ?>"

Clear cache: php bin/magento cache:clean

enter image description here

Method 2

You need to check this file for company field in vendor.


You can override this file here in your custom theme and you can change placeholder there.


Hope this will help you!

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

Leave a Reply