From 4ef662d1cad00adef17d1d111d47dff11d915291 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 22 Oct 2019 09:59:37 -0400 Subject: [PATCH] reivew --- MVMCoreUI/Molecules/RadioButton.swift | 14 +++++++++++--- MVMCoreUI/Molecules/RadioButtonModel.swift | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Molecules/RadioButton.swift b/MVMCoreUI/Molecules/RadioButton.swift index 57115d68..059bc5b6 100644 --- a/MVMCoreUI/Molecules/RadioButton.swift +++ b/MVMCoreUI/Molecules/RadioButton.swift @@ -16,12 +16,21 @@ import UIKit var fieldKey: String? var formValue: Bool? var isRequired: Bool = false - var radioButtonModel: RadioButtonModel? - + lazy var radioGroupName: String? = { [unowned self] in return json?.optionalStringForKey("radioGroupName") ?? json?.optionalStringForKey("fieldKey") }() + + lazy var radioButtonModel: RadioButtonModel? = { + [unowned self] in + if let radioGroupName = radioGroupName, + let radioButtonModel = delegateObject?.formValidationProtocol?.formValidatorModel?()?.radioButtonsModelByGroup[radioGroupName] { + return radioButtonModel + } else { + return nil + } + }() // MARK: - Inits public init() { @@ -101,6 +110,5 @@ extension RadioButton { let radioButtonModel = RadioButtonModel.setupForRadioButtonGroup(radioButton: self, formValidator: delegateObject?.formValidationProtocol?.formValidatorModel?()) FormValidator.setupValidation(molecule: radioButtonModel, delegate: delegateObject?.formValidationProtocol) - self.radioButtonModel = radioButtonModel } } diff --git a/MVMCoreUI/Molecules/RadioButtonModel.swift b/MVMCoreUI/Molecules/RadioButtonModel.swift index 68e95790..a72bd889 100644 --- a/MVMCoreUI/Molecules/RadioButtonModel.swift +++ b/MVMCoreUI/Molecules/RadioButtonModel.swift @@ -49,6 +49,6 @@ extension RadioButtonModel: FormValidationFormFieldProtocol { } // The field value key value pair for sending to server @objc public func formFieldValue() -> Any? { - return selectedRadioButton != nil ? true : false + return selectedRadioButton != nil ? true : false } }