added action attribute for radiobutton
This commit is contained in:
parent
abdb0d7e11
commit
a8e13263e6
@ -9,7 +9,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class RadioButton: Control {
|
@objcMembers open class RadioButton: Control,MFButtonProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -99,6 +99,9 @@ import UIKit
|
|||||||
} else {
|
} else {
|
||||||
isSelected = !isSelected
|
isSelected = !isSelected
|
||||||
}
|
}
|
||||||
|
if let actionModel = radioModel?.action, isSelected {
|
||||||
|
Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: nil)
|
||||||
|
}
|
||||||
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
|
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
|
||||||
setNeedsDisplay()
|
setNeedsDisplay()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
public var baseValue: AnyHashable?
|
public var baseValue: AnyHashable?
|
||||||
public var groupName: String = FormValidator.defaultGroupName
|
public var groupName: String = FormValidator.defaultGroupName
|
||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
|
public var action: ActionModelProtocol?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
@ -39,6 +40,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
case fieldValue
|
case fieldValue
|
||||||
case fieldKey
|
case fieldKey
|
||||||
case groupName
|
case groupName
|
||||||
|
case action
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -81,6 +83,7 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
self.groupName = groupName
|
self.groupName = groupName
|
||||||
}
|
}
|
||||||
fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue)
|
fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue)
|
||||||
|
action = try typeContainer.decodeModelIfPresent(codingKey: .action)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -92,5 +95,6 @@ open class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
|||||||
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
||||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||||
try container.encodeIfPresent(fieldValue, forKey: .fieldValue)
|
try container.encodeIfPresent(fieldValue, forKey: .fieldValue)
|
||||||
|
try container.encodeModelIfPresent(action, forKey: .action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user