Borales/yii2-phone-input

The number field gets changed when yii form validation fails

Opened this issue · 0 comments

Hi Barols,
thanks for your easy-to-use package.
Actually I have a problem and a solution for it.

My problem is when there is a validation error in the Yii-active-form,

the yii2-phone-input widget would change the phone input with the E::164 mobile format number, because the listener is on the form submit event.

my Expected behavior is: just changing the mobile number when form is ready to get send.

propose

so my suggestion is to use this event : beforeSubmit instead of the submit event, which will be run in the yii active form js.

another problem I have is when I want to remove the listener when I want, I just can't,
because anonymous function binding for listeners, cannot be detached.

so my suggestion for this would be to just make the function as a named function (it can be combined with the field name like : makeIntNumber$id ) so it can be detached if anyone wants to.

regards,

P.S: if you have not the time, I would be happy to fix it myself & make the PR