diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift index 6bbef151..e29081ea 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryField.swift @@ -317,6 +317,13 @@ import UIKit }) } + model.updateUIDynamicError = { [weak self] in + MVMCoreDispatchUtility.performBlock(onMainThread: { + guard let self = self else { return } + self.updateValidation(model.isValid ?? false) + }) + } + title = model.title feedback = model.feedback isEnabled = model.enabled diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift index 02affc3d..f70110ec 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift @@ -22,7 +22,12 @@ import Foundation public var accessibilityIdentifier: String? public var title: String? public var feedback: String? - public var dynamicErrorMessage: String? + public var dynamicErrorMessage: String? { + didSet { + isValid = false + updateUIDynamicError?() + } + } public var errorMessage: String? public var errorTextColor: Color? public var enabled: Bool = true @@ -43,6 +48,8 @@ import Foundation /// Temporary binding mechanism for the view to update on enable changes. public var updateUI: ActionBlock? + public var updateUIDynamicError: ActionBlock? + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 93e7ceb0..fc24d69f 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -449,18 +449,11 @@ import UIKit let entryFieldModel = formValidator?.fields[fieldName] as? EntryFieldModel else { continue } - entryFieldModel.dynamicErrorMessage = userError - entryFieldModel.isValid = false - if fieldError["clearText"] as? Bool ?? true { entryFieldModel.text = "" } - DispatchQueue.main.async { [self] in - if let view = UIView.findByAccessibility(identifier: fieldName), let moleculeView = view as? MoleculeViewProtocol { - moleculeView.set(with: entryFieldModel, delegateObjectIVar, nil) - } - } + entryFieldModel.dynamicErrorMessage = userError } }