Default magento checkout behavior when using new customer billing address form (related to newCustomerBillingAddress name in the local storage).
- we uncheck "My billing and shipping address are the same" checkbox
- the new customer billing address form is shown
- we start to fill some data into the fields. for example "first name".
- we remove this "first name" value and we see validation error
- we click again "cancel" at the bottom or the checkbox "my billing and shipping address are the same"
- form is hidden
- we uncheck the "my billing and shipping address are the same"
- we see the form and the validation errors
My questions are related to step nr 7 and 8.
Q1: how to clear validation errors in the form when action in step 7 happens and we see form (step 8) ? How to do it when we show form using our custom functions to show/hide form and select different addresses (when user is logged) ? I would like example of function that I could put into view/billing-address.js that will clear validation error in/after step nr 8.
Q2: Why if user click "cancel" magento saves the changed input values? I guess it's because keyUp event in Magento Ui?
I've made some changes that if:
p1. user fill the form and click "save". data is valid so store in some observable/localStorage
p2. user edits the form data. Ex. He removes the first name field.. but than he clicks cancel button
in p2 step I compare previous valid form data to the new form data.
If the field has different value than I restore the valid one and I have to trigger keyUp for fields that were modified to hide the validation error.
I know I do it the wrong way... but how can I access in billing-address.js every billing address form's field (to set new value / clear validation / revalidate) ?
extra question - why magento2 knockout's billing-address.js methods are executed in every payment method scope (this.dataScopePrefix) even if we turn on in store only one or two or X payment methods?