@@ -53,7 +53,7 @@ export default {
53
53
if ( isFunction ( this . schema . set ) ) {
54
54
this . schema . set ( this . model , newValue ) ;
55
55
changed = true ;
56
-
56
+
57
57
} else if ( this . schema . model ) {
58
58
this . setModelValueByPath ( this . schema . model , newValue ) ;
59
59
changed = true ;
@@ -68,7 +68,7 @@ export default {
68
68
69
69
if ( this . $parent . options && this . $parent . options . validateAfterChanged === true ) {
70
70
this . validate ( ) ;
71
- }
71
+ }
72
72
}
73
73
}
74
74
}
@@ -133,7 +133,7 @@ export default {
133
133
setModelValueByPath ( path , value ) {
134
134
// convert array indexes to properties
135
135
let s = path . replace ( / \[ ( \w + ) \] / g, ".$1" ) ;
136
-
136
+
137
137
// strip a leading dot
138
138
s = s . replace ( / ^ \. / , "" ) ;
139
139
@@ -157,9 +157,36 @@ export default {
157
157
this . $root . $set ( o , k , value ) ;
158
158
return ;
159
159
}
160
-
160
+
161
161
++ i ;
162
162
}
163
+ } ,
164
+
165
+ getFieldID ( schema ) {
166
+ // Try to get a reasonable default id from the schema,
167
+ // then slugify it.
168
+ if ( typeof schema . id !== "undefined" ) {
169
+ // If an ID's been explicitly set, use it unchanged
170
+ return schema . id ;
171
+ } else {
172
+ // Return the slugified version of either:
173
+ return ( schema . inputName || schema . label || schema . model )
174
+ // NB: This is a very simple, conservative, slugify function,
175
+ // avoiding extra dependencies.
176
+ . toString ( )
177
+ . trim ( )
178
+ . toLowerCase ( )
179
+ // Spaces & underscores to dashes
180
+ . replace ( / | _ / g, "-" )
181
+ // Multiple dashes to one
182
+ . replace ( / - { 2 , } / g, "-" )
183
+ // Remove leading & trailing dashes
184
+ . replace ( / ^ - + | - + $ / g, "" )
185
+ // Remove anything that isn't a (English/ASCII) letter, number or dash.
186
+ . replace ( / ( [ ^ a - z A - Z 0 - 9 - ] + ) / g, "" )
187
+ ;
188
+ }
163
189
}
190
+
164
191
}
165
192
} ;
0 commit comments