File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,21 @@ export default {
23
23
}
24
24
25
25
this . mask = IMask ( this . maskedInput , this . maskOptions )
26
+ this . mask . unmaskedValue = this . rawValue ( this . hiddenInput . value )
27
+ this . mask . on ( 'accept' , this . handleMaskChange . bind ( this ) )
28
+ } ,
29
+ updated ( ) {
30
+ this . handleMaskChange . bind ( this )
31
+ } ,
32
+ handleMaskChange ( ) {
33
+ this . hiddenInput . value = this . rawValue ( this . mask . value )
34
+ this . hiddenInput . dispatchEvent ( new Event ( 'input' , { bubbles : true } ) )
35
+ } ,
36
+ rawValue ( value ) {
37
+ return value
38
+ . replace ( this . el . dataset . unit || '' , '' )
39
+ . trim ( )
40
+ . replace ( new RegExp ( `\\${ this . el . dataset . thousandsSeparator } ` , 'g' ) , '' )
26
41
} ,
27
42
destroyed ( ) {
28
43
this . mask . destroy ( )
Original file line number Diff line number Diff line change @@ -231,15 +231,8 @@ defmodule Backpex.HTML.Form do
231
231
@ input_class || "[&_>_input]:input [&_>_input]:w-full" ,
232
232
@ errors != [ ] && ( @ error_class || "[&_>_input]:input-error [&_>_input]:bg-error/10" )
233
233
] } >
234
- < input
235
- id = { "#{ @ id } _masked" }
236
- name = { @ name }
237
- value = { @ value }
238
- data-masked-input
239
- phx-update = "ignore "
240
- class = { @ input_class }
241
- { @ rest }
242
- />
234
+ < input id = { "#{ @ id } _masked" } name = { @ name } data-masked-input phx-update = "ignore " { @ rest } />
235
+ < input type = "hidden " value = { @ value } name = { @ name } data-hidden-input />
243
236
</ span >
244
237
</ div >
245
238
< . error :for = { msg <- @ errors } :if = { not @ hide_errors } > { msg } </ . error >
You can’t perform that action at this time.
0 commit comments