0

I want to force taxvat field as not required on customer create form Even if i have ovrride

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

with a plugin in my custom module

<div class="field taxvat">
<label class="label" for="<?= $block->escapeHtmlAttr($block->getFieldId('taxvat')) ?>"><span><?= $block->escapeHtml($block->getStoreLabel('taxvat')) ?></span></label>
<div class="control">
    <input type="text" id="<?= $block->escapeHtmlAttr($block->getFieldId('taxvat')) ?>" name="<?= $block->escapeHtmlAttr($block->getFieldName('taxvat')) ?>" value="<?= $block->escapeHtmlAttr($block->getTaxvat()) ?>" title="<?= $block->escapeHtmlAttr($block->getStoreLabel('taxvat')) ?>" class="input-text ">
</div>

removing data-validate="{required:true}"

when i submit form it get me error "Tax/VAT Number" is a required value.

enter image description here

2 Answers 2

0

That should be manageable from admin. Location:

Stores -> Configuration -> Customer -> Customer Configuration -> Name and Address Options

enter image description here

1
  • yes off course but i need a programmatically way :(
    – Altravista
    Nov 30, 2019 at 10:17
0

solution is to override validateValue function in class

\Magento\Eav\Model\Attribute\Data\Text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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