This repository was archived by the owner on Jun 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
src/components/dynamic-form Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -151,14 +151,14 @@ export default defineComponent({
151
151
}
152
152
153
153
function mapControls(empty ? ) {
154
- controls . value =
154
+ const controlArray =
155
155
Object .entries (props .form ?.fields ).map (
156
156
([key , field ]: [string , InputBase ]) =>
157
157
empty
158
158
? ({
159
159
... field ,
160
160
name: key ,
161
- value: undefined ,
161
+ value: null ,
162
162
dirty: false ,
163
163
touched: false ,
164
164
} as FormControl )
@@ -169,6 +169,13 @@ export default defineComponent({
169
169
touched: false ,
170
170
} as FormControl ),
171
171
) || [];
172
+ if (props .form .fieldOrder ) {
173
+ controls .value = controlArray .sort (
174
+ (a : FormControl , b : FormControl ) =>
175
+ props .form .fieldOrder .indexOf (a .name ) -
176
+ props .form .fieldOrder .indexOf (b .name ),
177
+ );
178
+ }
172
179
}
173
180
174
181
function resetForm() {
Original file line number Diff line number Diff line change @@ -2,5 +2,6 @@ import { InputBase } from '@/core/models';
2
2
3
3
export interface DynamicForm {
4
4
id : string ;
5
- fields : InputBase < any > [ ] ;
5
+ fields : InputBase [ ] ;
6
+ fieldOrder ?: string [ ] ;
6
7
}
You can’t perform that action at this time.
0 commit comments