- The value is being saved incorrectly in the DataField. It's saving the
ItemIndex + 1(for example, if the first line[0]is selected, the saved value is1). - Additionally, the
Valuesproperty is not working.
I can't reproduce any issue with TWebDBRadioGroup.
Test project is here:
Project3.zip (9.7 KB)
I extended my tests; the bug occurs when the field is ftInteger with Values set, and it always occurs when Values is empty. I've attached a more complete test project — if line 91 is changed, the behavior is different.
Project3_v2.zip (12.0 KB)
It is by design that the persisted value in the DB is a 1-based index.
Zero is used to store no-selection.
In the standard Delphi TRadioGroup, when there is no selection, the ItemIndex returns -1. However, when using the Values property, the first item (at index 0 with value 0) fails to takes its selection correctly and unexpectedly changes to 1.
I could not see a difference in handling between the case of using Values and using no Values when mapping is on an integer field
Project3_v3.zip (11.9 KB)
I attached an example. Press the Bug button to see differences with values.
Values is a list of strings, so this string value is only used to persist in the dataset when the field type is ftString. When the field type is ftInteger, the selected index (1-based) is used.