0

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

app\design\frontend\Company_name\Magento_Customer\templates\address\edit.phtml

getLayout()->createBlock('Magento\Customer\Block\Widget\Company') ?>
<?php if ($_company->isEnabled()): ?>
    <?= $_company->setCompany($block->getAddress()->getCompany())->toHtml() ?>
<?php endif ?>

enter image description here

0

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

<?php
/**
 * 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">
        <span>
            <?= $block->escapeHtml(__('Company')) ?>
        </span>
    </label>
    <div class="control">
            <?php
            $_validationClass = $block->escapeHtmlAttr(
                $this->helper(\Magento\Customer\Helper\Address::class)
                     ->getAttributeValidationClass('company')
            );
            ?>
        <input type="text"
               name="company"
               id="company" placeholder="Company Placeholder"
               value="<?= $block->escapeHtmlAttr($block->getCompany()) ?>"
               title="<?= $block->escapeHtmlAttr(__('Company')) ?>"
               class="input-text <?= $_validationClass ?: '' ?>"
         >
    </div>
</div>

Clear cache: php bin/magento cache:clean

enter image description here

| improve this answer | |
  • Its working well as earlier I was making changes in /vendor/magento/module-ui/view/frontend/web/templates/form/element so kinda confused – J. Doe Nov 14 '19 at 16:25
  • This file is proper. So do not worry about that. – Dhaduk Mitesh Nov 16 '19 at 4:28
0

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

vendor/magento/module-customer/view/frontend/templates/widget/company.phtml

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

app/design/frontend/Vendor/Theme/Magento_Customer/templates/widget/company.phtml

Hope this will help you!

| improve this answer | |

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.