File tree Expand file tree Collapse file tree 4 files changed +427
-410
lines changed Expand file tree Collapse file tree 4 files changed +427
-410
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,25 @@ export default function(Vue){
3
3
* Allows the user to pass extra attributes that should be added to the element. Such as placeholder etc etc
4
4
* @param {Object } value
5
5
*/
6
- Vue . directive ( 'formly-atts' , function ( value ) {
7
- if ( typeof value == 'undefined' ) return ;
8
- /*
9
- Object.keys(value).forEach((key) => {
10
- this.el.setAttribute(key, value[key]);
11
- });
12
- */
6
+ Vue . directive ( 'formly-atts' , {
7
+ bind :function ( el , binding ) {
8
+
9
+ if ( ! binding . value ) return ;
10
+
11
+ Object . keys ( binding . value ) . forEach ( ( key ) => {
12
+ el . setAttribute ( key , value [ key ] ) ;
13
+ } ) ;
14
+
15
+ }
13
16
} ) ;
17
+
18
+
19
+ Vue . directive ( 'formly-input-type' , {
20
+ bind : function ( el , binding ) {
21
+ if ( ! binding . value ) return ;
22
+
23
+ el . setAttribute ( 'type' , binding . value ) ;
24
+ }
25
+ } ) ;
26
+
14
27
}
Original file line number Diff line number Diff line change @@ -18,19 +18,19 @@ export default
18
18
if ( typeof this . to [ action ] == 'function' ) this . to [ action ] . call ( this , e ) ;
19
19
} ,
20
20
onFocus : function ( e ) {
21
- this . $set ( 'form.' + this . field . key + '. $active', true ) ;
21
+ this . $set ( this . form [ this . field . key ] , ' $active', true ) ;
22
22
this . runFunction ( 'onFocus' , e ) ;
23
23
} ,
24
24
onBlur : function ( e ) {
25
- this . $set ( 'form.' + this . field . key + '. $dirty', true ) ;
26
- this . $set ( 'form.' + this . field . key + '. $active', false ) ;
25
+ this . $set ( this . form [ this . field . key ] , ' $dirty', true ) ;
26
+ this . $set ( this . form [ this . field . key ] , ' $active', false ) ;
27
27
this . runFunction ( 'onBlur' , e ) ;
28
28
} ,
29
29
onClick : function ( e ) {
30
30
this . runFunction ( 'onClick' , e ) ;
31
31
} ,
32
32
onChange : function ( e ) {
33
- this . $set ( 'form.' + this . field . key + '. $dirty', true ) ;
33
+ this . $set ( this . form [ this . field . key ] , ' $dirty', true ) ;
34
34
this . runFunction ( 'onChange' , e ) ;
35
35
} ,
36
36
onKeyup : function ( e ) {
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" form-group formly-input" :class =" [ to.type, {'formly-has-value': model[field.key], 'formly-has-focus': form[field.key].$active}]" >
3
3
<label v-if =" to.label" :for =" to.id ? to.id : null" >{{to.label}}</label >
4
- <input class =" form-control" :class =" to.classes" :id =" to.id ? to.id : null" : type =" to.type || text" v-model =" model[field.key]" @blur =" onBlur" @focus =" onFocus" @click =" onClick" @change =" onChange" @keyup =" onKeyup" @keydown =" onKeydown" v-formly-atts =" to.atts" >
4
+ <input class =" form-control" :class =" to.classes" :id =" to.id ? to.id : null" type =" text" v-model =" model[field.key]" @blur =" onBlur" @focus =" onFocus" @click =" onClick" @change =" onChange" @keyup =" onKeyup" @keydown =" onKeydown" v-formly-atts =" to.atts" >
5
5
</div >
6
6
</template >
7
7
11
11
mixins: [baseField],
12
12
methods: {
13
13
onChange : function (e ){
14
- /*
15
- this.$set('form.'+ this.key+'. $dirty', true);
14
+
15
+ this .$set (this . form [ this .field . key ], ' $dirty' , true );
16
16
this .runFunction (' onChange' , e);
17
- if ( this.form[this.key].inputType == 'file' ){
18
- this.$set('form.'+ this.key+'.files' , this.$el.querySelector('input').files);
17
+ if ( this .to . type == ' file' ){
18
+ this .$set (this . model , this .field . key , this .$el .querySelector (' input' ).files );
19
19
}
20
- */
20
+
21
21
}
22
22
}
23
23
}
You can’t perform that action at this time.
0 commit comments