PDA

View Full Version : [FIXED] RadioGroup isValid does nothing



gslender
12 Aug 2008, 4:19 PM
RadioGroup implements isValid and calls radio.isValid() but isValid is not implemented by radio - only the default Field.isValid is called, which calls validateField() which is also not implemented in radio or checkbox. So nothing happens of value for radio/checkbox

RadioGroup (and CheckBoxGroup) should probably have an implementation that at least checks to see if a value is set on any radio/checkbox - or at least explain what the purpose of the isValid method is as it seems to do nothing.

Current workaround is to override isvalid, but future versions should provide a better solution.

gslender
12 Aug 2008, 4:54 PM
simple workaround that may help other folks....


radioGroup = new RadioGroup() {
@Override
public boolean isValid() {
for (Radio radio : fields) {
if (new Boolean(radio.getRawValue())) return true;
}

markInvalid("A selection is required");
return false;
}

@Override
protected void onRadioSelected(Radio radio) {
super.onRadioSelected(radio);
clearInvalid();
}
};

darrellmeyer
13 Aug 2008, 12:23 PM
Fix is in SVN.