try { constnewFormSubmissionResult = awaitsubmissionService.submit({ formSubmission, }) if ( newFormSubmissionResult.isOffline && !newFormSubmissionResult.isInPendingQueue ) { thrownewOneBlinkAppsError( 'You cannot submit this form while offline, please try again when connectivity is restored.', { isOffline:true, }, ) }
The OneBlinkAutoSaveForm component does not offer props to allow for a
controlled form (i.e. having access to submission and definition values).
To implement a controlled version of the <OneBlinkAutoSaveForm />
component, use the example component below.
// This is just an example of how you could intercept // the change event when a user enters/selects a value // on the form. constcustomSetFormSubmission = React.useCallback( (formSubmission) => { setFormSubmission((currentFormSubmission) => { constnewFormSubmission = typeofformSubmission === 'function' ? formSubmission(currentFormSubmission) : formSubmission
// This is where you can access the updated // submission data or form definition. // You could even change the form definition // programmatically based on user inputs. console.log( 'A change has occurred to the submission', newFormSubmission.submission, ) newFormSubmission.definition.isInfoPage = !newFormSubmission.submission.doesTheUserNeedToSubmit
if (isLoadingAutoSaveSubmission) { return<p>Checking for auto save data...</p> }
if (isAutoSaveSubmissionAvailable) { return ( <> <p>Do you want to use the auto save data?</p> <buttononClick={startNewSubmission}>No, start again</button> <buttononClick={continueAutoSaveSubmission}> Yes, continue </button> </> ) }
Similar to OneBlinkForm, however requires props to control the
definition
andsubmission
values.Example
Implementing Controlled Auto Save
The OneBlinkAutoSaveForm component does not offer props to allow for a controlled form (i.e. having access to
submission
anddefinition
values). To implement a controlled version of the<OneBlinkAutoSaveForm />
component, use the example component below.