3

I have overrided customer edit form. But while saving record I'm getting error message

"Telephone" is a required value.

I don't want telephone field. So in my form telephone field is not there but still error is coming.

  • 1
    Now try this Store -> Configuration -> Customer Configuration Tab -> Name and Address Options -> Show Telephone Required just set No and save it. – Ravindrasinh Zala Oct 23 '17 at 10:27
  • @RavindrasinhZala but there is no Telephone field under Customer Configuration tab – jassi Oct 23 '17 at 10:46
4

There is a Magento2 feature that is by default telephone field is required. There is a lot of discussion on below topic:

https://github.com/magento/magento2/issues/1691

There is also a suggestion on this topic that we can make it optional by running SQL script

update eav_attribute set is_required=0 where attribute_code='telephone';

Read full topic and then run the query.

Note: Take a backup of DB before making any change.

After run query check eav_attribute table and make sure attribute column value changed to is_required to 0.enter image description here

Run reindex command for attributes only

php bin/magento indexer:reindex catalog_product_attribute

and delete all cache and static files, compile and regenerate code by below command

php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

Hope this will help you.

| improve this answer | |
  • I have done all changes but getting same error – jassi Oct 23 '17 at 12:34
  • did you reindex?since you have changed attribute hence you will require fully reindex and then clear all cache. – akgola Oct 23 '17 at 12:39
  • Now I have done reindexing. But still same issue exist – jassi Oct 23 '17 at 12:48
  • I have put hidden value <input type="text" id="telephone" name="telephone" value="999999999"> . But still does not work – jassi Oct 23 '17 at 13:12
  • update answer check it and try to fully delete all cache and reindex. – akgola Oct 23 '17 at 13:29
1

You can remove telephone field from using following changes.

  • Using sql query update eav_attribute set is_required=0 where attribute_code='telephone';
  • Modified Magento\Sales\Model\Order\Address\Validator::validateForCustomer()
  • Modified Magento\Customer\Model\ResourceModel \AddressRepository::_validate()
  • Modified Magento\Customer\Model\Address\AbstractAddress::validate()
| improve this answer | |
  • I have done all changes but getting same error – jassi Oct 23 '17 at 12:34
  • please try with clear cache, and regenerate static content. – Aasim Goriya Oct 23 '17 at 12:46
  • I have put hidden value <input type="text" id="telephone" name="telephone" value="999999999"> . But still does not work – jassi Oct 23 '17 at 13:12
  • @AasimGoriya what specifically did you modify in those classes? Thanks. – dchayka Nov 15 '18 at 0:35
0

I followed the steps in the answer by akgola, except instead of following the step:

php bin/magento indexer:reindex catalog_product_attribute

I instead ran

php bin/magento indexer:reindex customer_grid

and this worked for me. It is a customer and not product attribute being updated, so that is probably why that answer isn't working for others?

| 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.