@@ -206,11 +206,14 @@ export class DynamicForm extends React.Component<
206206 } else if ( Array . isArray ( val . newValue ) && val . newValue . length === 0 ) {
207207 val . fieldDefaultValue = null ;
208208 shouldBeReturnBack = true ;
209+ } else if ( val . fieldType === "Number" ) {
210+ shouldBeReturnBack = this . validateNumberOnSubmit ( val ) ;
211+ }
212+ } else if ( val . fieldType === "Number" ) {
213+ if ( val . newValue === null ) {
214+ val . newValue = val . fieldDefaultValue ;
209215 }
210- } else if ( val . fieldType === "Number" ) {
211- if ( ( val . newValue < val . minimumValue ) || ( val . newValue > val . maximumValue ) ) {
212- shouldBeReturnBack = true ;
213- }
216+ shouldBeReturnBack = this . validateNumberOnSubmit ( val ) ;
214217 }
215218 } ) ;
216219 if ( shouldBeReturnBack ) {
@@ -848,4 +851,20 @@ export class DynamicForm extends React.Component<
848851
849852 return errorMessage ;
850853 } ;
854+
855+ private validateNumberOnSubmit = ( val :IDynamicFieldProps ) : boolean => {
856+ let shouldBeReturnBack = false ;
857+ if ( val . fieldType === "Number" && val . showAsPercentage ) {
858+ const minValue = val . minimumValue !== undefined ? val . minimumValue * 100 : undefined ;
859+ const maxValue = val . maximumValue !== undefined ? val . maximumValue * 100 : undefined ;
860+ if ( ( val . newValue < minValue ) || ( val . newValue > maxValue ) ) {
861+ shouldBeReturnBack = true ;
862+ }
863+ } else if ( val . fieldType === "Number" && ! val . showAsPercentage ) {
864+ if ( ( val . newValue < val . minimumValue ) || ( val . newValue > val . maximumValue ) ) {
865+ shouldBeReturnBack = true ;
866+ }
867+ }
868+ return shouldBeReturnBack ;
869+ }
851870}
0 commit comments