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){
33 * Allows the user to pass extra attributes that should be added to the element. Such as placeholder etc etc
44 * @param {Object } value
55 */
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+ }
1316 } ) ;
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+
1427}
Original file line number Diff line number Diff line change @@ -18,19 +18,19 @@ export default
1818 if ( typeof this . to [ action ] == 'function' ) this . to [ action ] . call ( this , e ) ;
1919 } ,
2020 onFocus : function ( e ) {
21- this . $set ( 'form.' + this . field . key + '. $active', true ) ;
21+ this . $set ( this . form [ this . field . key ] , ' $active', true ) ;
2222 this . runFunction ( 'onFocus' , e ) ;
2323 } ,
2424 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 ) ;
2727 this . runFunction ( 'onBlur' , e ) ;
2828 } ,
2929 onClick : function ( e ) {
3030 this . runFunction ( 'onClick' , e ) ;
3131 } ,
3232 onChange : function ( e ) {
33- this . $set ( 'form.' + this . field . key + '. $dirty', true ) ;
33+ this . $set ( this . form [ this . field . key ] , ' $dirty', true ) ;
3434 this . runFunction ( 'onChange' , e ) ;
3535 } ,
3636 onKeyup : function ( e ) {
Original file line number Diff line number Diff line change 11<template >
22 <div class =" form-group formly-input" :class =" [ to.type, {'formly-has-value': model[field.key], 'formly-has-focus': form[field.key].$active}]" >
33 <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" >
55 </div >
66</template >
77
1111 mixins: [baseField],
1212 methods: {
1313 onChange : function (e ){
14- /*
15- this.$set('form.'+ this.key+'. $dirty', true);
14+
15+ this .$set (this . form [ this .field . key ], ' $dirty' , true );
1616 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 );
1919 }
20- */
20+
2121 }
2222 }
2323 }
You can’t perform that action at this time.
0 commit comments