File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
simplr-forms-dom/src/components Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -27,16 +27,16 @@ export class Form extends BaseForm<FormProps, {}> {
27
27
return ;
28
28
}
29
29
30
- // TODO: Touch all fields to validate
30
+ this . FormStore . SetFieldsTouched ( ) ;
31
31
32
32
if ( this . props . onSubmit == null ) {
33
33
return ;
34
34
}
35
35
36
- // Persist synthetic event, because it's passed into another method
36
+ // Persist synthetic event, because it's passed into another method.
37
37
event . persist ( ) ;
38
38
39
- // Pass onSubmit result to FormStore for further processing
39
+ // Pass onSubmit result to FormStore for further processing.
40
40
const result = this . props . onSubmit ( event , this . FormStore ) ;
41
41
this . FormStore . SubmitForm ( result ) ;
42
42
}
Original file line number Diff line number Diff line change @@ -379,6 +379,26 @@ export class FormStore extends ActionEmitter {
379
379
}
380
380
}
381
381
382
+ public SetFieldsTouched ( fieldsIds ?: string [ ] ) : void {
383
+ this . State = this . State . withMutations ( state => {
384
+ if ( fieldsIds == null ) {
385
+ fieldsIds = state . Fields . keySeq ( ) . toArray ( ) ;
386
+ }
387
+
388
+ fieldsIds . forEach ( fieldId => {
389
+ const fieldState = state . Fields . get ( fieldId ) ;
390
+
391
+ if ( fieldState != null ) {
392
+ state . Fields = state . Fields . set ( fieldId , fieldState . merge ( {
393
+ Touched : true
394
+ } as FieldStoreState ) ) ;
395
+ }
396
+ } ) ;
397
+
398
+ return this . RecalculateDependentFormStatuses ( state ) ;
399
+ } ) ;
400
+ }
401
+
382
402
public async ValidateForm ( validationPromise : Promise < never > ) : Promise < void > {
383
403
const form = this . State . Form ;
384
404
You can’t perform that action at this time.
0 commit comments