Flex:RadioButtonGroup 上的验证器
我在包含 2 个单选按钮的 RadioButtonGroup 上有一个验证器。 RadioButtonGroup 上方有一个复选框,如果 checkbox.Selected
,则启用单选按钮。 因此,如果 checkbox.Selected
则需要验证器。到目前为止,一切都很好。
问题是一旦选择了radio
,RadioButtonGroup selectedValue 就会被设置。当我取消选中该复选框时,我将单选按钮设置为未选中,但 RadioButtonGroup 上的 selectedValue 不会重置 - 它保留以前的值。我尝试将其设置为 null 但没有成功。
因此,如果我再次选中该复选框并提交,验证器会在 RadioButtonGroup 上看到 selectedValue。即使没有选择任何无线电,验证也会通过。
当我取消选中复选框时,如何将 RadioButtonGroup 重置为其初始状态?
谢谢。
聚苯乙烯 我查看了 RadioButtonGroup.selectedValue = null
的底层代码,它的作用是在参数值中查找单选按钮。如果没有找到,则不会设置任何内容。
I have a Validator on a RadioButtonGroup of 2 Radios. There's a checkbox above the RadioButtonGroup whereby if checkbox.Selected
, then the Radios are enabled.
So the Validator is required if the checkbox.Selected
. So far so good.
The problem is once a radio
gets selected, the RadioButtonGroup selectedValue gets set. When I uncheck the checkbox I set the radios to not selected, but the selectedValue on the RadioButtonGroup doesn't get reset -- it hold the previous value. I tried setting it to null but no luck.
Therefore if I check the checkbox again and submit, the Validator see a selectedValue on the RadioButtonGroup. Even though none of the radios are selected, validation passes.
How can I reset the RadioButtonGroup to its initial state when I uncheck the CheckBox?
Thanks.
PS
I looked at the underlying code for RadioButtonGroup.selectedValue = null
, and what it does is look for a radio in the with the parameter value. If it doesn't find it nothing gets set.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RadioButtonGroup.selection 是否有同样的问题?如果没有,我建议改用它。
Does RadioButtonGroup.selection have the same problem? If not, I'd suggest using that instead.