From c8d628da3151c9d5326098e8fac47f34809ecdaf Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 7 Jan 2021 10:59:09 -0500 Subject: [PATCH] changes --- .../Atomic/Atoms/FormFields/TextFields/EntryField.swift | 6 +++++- .../Atoms/FormFields/TextFields/EntryFieldModel.swift | 1 + MVMCoreUI/BaseControllers/ViewController.swift | 5 +---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift index 16d36bc7..8ecfc04d 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift @@ -320,7 +320,11 @@ import UIKit model.updateUIDynamicError = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { guard let self = self else { return } - self.updateValidation(model.isValid ?? false) + let validState = model.isValid ?? false + self.updateValidation(validState) + if !validState && model.shouldClearText { + self.text = "" + } }) } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift index c9d60bfe..ef5c57e9 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift @@ -22,6 +22,7 @@ import Foundation public var accessibilityIdentifier: String? public var title: String? public var feedback: String? + public var shouldClearText: Bool = false public var dynamicErrorMessage: String? { didSet { isValid = dynamicErrorMessage?.isEmpty ?? true diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index fc24d69f..dcaf611e 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -449,10 +449,7 @@ import UIKit let entryFieldModel = formValidator?.fields[fieldName] as? EntryFieldModel else { continue } - if fieldError["clearText"] as? Bool ?? true { - entryFieldModel.text = "" - } - + entryFieldModel.shouldClearText = fieldError["clearText"] as? Bool ?? true entryFieldModel.dynamicErrorMessage = userError } }