This repository was archived by the owner on Aug 23, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -102,8 +102,15 @@ const propTypes = {
102
102
persist : PropTypes . bool ,
103
103
getValue : PropTypes . func ,
104
104
isToggle : PropTypes . bool ,
105
+
106
+ // HTML5 attributes
107
+ formNoValidate : PropTypes . bool ,
105
108
} ;
106
109
110
+ const htmlAttributes = [ 'formNoValidate' ] ;
111
+ const disallowedPropTypeKeys = Object . keys ( propTypes )
112
+ . filter ( key => htmlAttributes . indexOf ( key ) === - 1 ) ;
113
+
107
114
const defaultStrategy = {
108
115
get : _get ,
109
116
getFieldFromState,
@@ -320,10 +327,10 @@ function createControlClass(s = defaultStrategy) {
320
327
getNodeErrors ( ) {
321
328
const {
322
329
node,
323
- props : { fieldValue } ,
330
+ props : { fieldValue, formNoValidate } ,
324
331
} = this ;
325
332
326
- if ( ! node || ( node && ! node . willValidate ) ) {
333
+ if ( formNoValidate || ! node || ( node && ! node . willValidate ) ) {
327
334
this . willValidate = false ;
328
335
return null ;
329
336
}
@@ -637,7 +644,7 @@ function createControlClass(s = defaultStrategy) {
637
644
638
645
const finalControlProps = {
639
646
...controlProps ,
640
- ...omit ( props , Object . keys ( propTypes ) ) ,
647
+ ...omit ( props , disallowedPropTypeKeys ) ,
641
648
} ;
642
649
643
650
const modelString = getModel ( model , state ) ;
Original file line number Diff line number Diff line change @@ -53,8 +53,13 @@ const propTypes = {
53
53
54
54
// standard HTML attributes
55
55
action : PropTypes . string ,
56
+ noValidate : PropTypes . bool ,
56
57
} ;
57
58
59
+ const htmlAttributes = [ 'action' , 'noValidate' ] ;
60
+ const disallowedPropTypeKeys = Object . keys ( propTypes )
61
+ . filter ( key => htmlAttributes . indexOf ( key ) === - 1 ) ;
62
+
58
63
const defaultStrategy = {
59
64
get : _get ,
60
65
getForm,
@@ -305,12 +310,13 @@ function createFormClass(s = defaultStrategy) {
305
310
handleIntents ( ) {
306
311
const {
307
312
formValue,
313
+ noValidate,
308
314
} = this . props ;
309
315
310
316
formValue . $form . intents . forEach ( ( intent ) => {
311
317
switch ( intent . type ) {
312
318
case 'submit' : {
313
- if ( isValid ( formValue , { async : false } ) ) {
319
+ if ( noValidate || isValid ( formValue , { async : false } ) ) {
314
320
this . handleValidSubmit ( { clearIntents : intent } ) ;
315
321
} else {
316
322
this . handleInvalidSubmit ( { clearIntents : intent } ) ;
@@ -363,7 +369,7 @@ function createFormClass(s = defaultStrategy) {
363
369
formValue,
364
370
} = this . props ;
365
371
366
- const allowedProps = omit ( this . props , Object . keys ( propTypes ) ) ;
372
+ const allowedProps = omit ( this . props , disallowedPropTypeKeys ) ;
367
373
const renderableChildren = typeof children === 'function'
368
374
? children ( formValue )
369
375
: children ;
You can’t perform that action at this time.
0 commit comments