0

I have created a custom module to validate street fields during checkout process. I used this tutorial from Victor Tikhonchuk - How to apply custom validation on checkout shipping form field?. Itworks fine.

Now, I want to implement the same validation in customer address book - https://mysite/customer/address/edit/id/102917/ How can I implement this?

1 Answer 1

0

You need to do this by overiding the phtml file into your custom extension.

  1. Create customer_address_form.xml on the following locations.

app/code/VENDOR/EXTENSION/view/frontend/layout/customer_address_form.xml

add this code :

<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <update handle="customer_account"/> <body> <referenceBlock name="customer_address_edit"> <action method="setTemplate"> <argument name="template" xsi:type="string">VENDOR_EXTENSION::address/edit.phtml</argument> </action> </referenceBlock> </body> </page> 
  1. Now you need to copy edit.phtml file and put into your extension.

Copy from : vendor/magento/module-customer/view/frontend/templates/address/edit.phtml

To : app/code/VENDOR/EXTENSION/view/frontend/templates/address/edit.phtml

  1. Now you need to apply custom validation into your overide files.

app/code/VENDOR/EXTENSION/view/frontend/templates/address/edit.phtml

2
  • Thanks, i used this guide - store.magenest.com/blog/… Two problems. First, it only works for me in the default theme, blank or luma, and only on the first line of the street, street_1. On the next line - street_2 and streen_3 it does not work. And in my custom theme it just reloads the page after submitting, without validation and without errors in console. Commented Jun 30 at 8:16
  • @iskander you need to share the code into new question, so other can help you there. Commented Jun 30 at 10:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.