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
You need to do this by overiding the phtml file into your custom extension.
- Create
customer_address_form.xmlon 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>
- Now you need to copy
edit.phtmlfile 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
- Now you need to apply custom validation into your overide files.
app/code/VENDOR/EXTENSION/view/frontend/templates/address/edit.phtml
-
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.iskander– iskander2025年06月30日 08:16:36 +00:00Commented Jun 30 at 8:16
-
@iskander you need to share the code into new question, so other can help you there.Dhiren Vasoya– Dhiren Vasoya2025年06月30日 10:04:19 +00:00Commented Jun 30 at 10:04
Explore related questions
See similar questions with these tags.