diff --git a/Airship/AirshipCore/Source/FormState.swift b/Airship/AirshipCore/Source/FormState.swift index 75af8a02a..2fd49925c 100644 --- a/Airship/AirshipCore/Source/FormState.swift +++ b/Airship/AirshipCore/Source/FormState.swift @@ -193,6 +193,7 @@ public struct FormInputData { guard let value = value else { return nil } + return [ FormInputData.typeKey: "text_input", FormInputData.valueKey: value @@ -211,10 +212,6 @@ public struct FormInputData { childrenMap[value.identifier] = value.getData() } - guard !childrenMap.isEmpty else { - return nil - } - switch formType { case .form: return [ diff --git a/Airship/AirshipCore/Source/ThomasEnvironment.swift b/Airship/AirshipCore/Source/ThomasEnvironment.swift index 4703f0eac..acc56e158 100644 --- a/Airship/AirshipCore/Source/ThomasEnvironment.swift +++ b/Airship/AirshipCore/Source/ThomasEnvironment.swift @@ -48,10 +48,10 @@ class ThomasEnvironment : ObservableObject { return } - if let formResult = formState.toFormResult() { - self.delegate.onFormSubmitted(formResult: formResult, - layoutContext: layoutState.toLayoutContext()) - } + self.delegate.onFormSubmitted( + formResult: formState.toFormResult(), + layoutContext: layoutState.toLayoutContext() + ) let channelEditor = Airship.channel.editAttributes() let contactEditor = Airship.contact.editAttributes() @@ -209,12 +209,11 @@ private extension FormState { } } - func toFormResult() -> ThomasFormResult? { - if let data = self.data.toPayload() { - return ThomasFormResult(identifier: self.identifier, - formData: data) - } - return nil + func toFormResult() -> ThomasFormResult { + return ThomasFormResult( + identifier: self.identifier, + formData: self.data.toPayload() ?? [:] + ) } }