|
|
@@ -30,6 +30,7 @@ interface ContextProps {
|
|
|
onSubmit: () => void;
|
|
|
dispatchAction: (event: PorterFormAction) => void;
|
|
|
validationInfo: PorterFormValidationInfo;
|
|
|
+ getSubmitValues: () => PorterFormVariableList;
|
|
|
isReadOnly?: boolean;
|
|
|
}
|
|
|
|
|
|
@@ -376,7 +377,7 @@ export const PorterFormContextProvider: React.FC<Props> = (props) => {
|
|
|
using functions for each input to finalize the variables
|
|
|
This can take care of things like appending units to strings
|
|
|
*/
|
|
|
- const onSubmitWrapper = () => {
|
|
|
+ const getSubmitValues = () => {
|
|
|
// we start off with a base list of the current variables for fields
|
|
|
// that don't need any processing on top (for example: checkbox)
|
|
|
// the assign here is important because that way state.variable isn't mutated
|
|
|
@@ -411,7 +412,12 @@ export const PorterFormContextProvider: React.FC<Props> = (props) => {
|
|
|
)
|
|
|
);
|
|
|
if (props.doDebug) console.log(Object.assign.apply({}, varList));
|
|
|
- props.onSubmit(Object.assign.apply({}, varList));
|
|
|
+
|
|
|
+ return Object.assign.apply({}, varList);
|
|
|
+ };
|
|
|
+
|
|
|
+ const onSubmitWrapper = () => {
|
|
|
+ props.onSubmit(getSubmitValues());
|
|
|
};
|
|
|
|
|
|
if (props.doDebug) {
|
|
|
@@ -434,6 +440,7 @@ export const PorterFormContextProvider: React.FC<Props> = (props) => {
|
|
|
error: isValidated ? null : "Missing required fields",
|
|
|
},
|
|
|
onSubmit: onSubmitWrapper,
|
|
|
+ getSubmitValues,
|
|
|
}}
|
|
|
>
|
|
|
{props.children}
|