Currently, pyxform does not require labels for items in choice lists.
For dynamic selects, I can see an argument for them not being required because users could be building a list they only want to query and won't use in a select. However, I think that's pretty rare and for those advanced users, it's not a big deal to just add a label. In v1.4, if a user did build a dynamic select with a choice missing a label and used it in a select, there'd be a Validate error. In v1.5, there's a crash (narrowly addressed by #535).
For static selects, I don't see any use for a choice without a label. Currently there's no validation on this at all.
CC @MartijnR @pbowen-oc
def test_choices_without_labels__for_static_selects__allowed(self):
"""
Test choices without labels for static selects. Validate will NOT fail.
"""
self.assertPyxformXform(
md = """
| survey | | | |
| | type | name | label |
| | select_one choices | a | A |
| choices | | | |
| | list_name | name | label |
| | choices | 1 | |
| | choices | 2 | |
""",
xml__contains=[
'<value>1</value>'
],
)
def test_choices_without_labels__for_dynamic_selects__allowed_by_pyxform(self):
"""
Test choices without labels for dynamic selects. Validate will fail.
"""
self.assertPyxformXform(
md = """
| survey | | | | |
| | type | name | label | choice_filter |
| | select_one choices | a | A | true() |
| choices | | | |
| | list_name | name | label |
| | choices | 1 | |
| | choices | 2 | |
""",
run_odk_validate=False,
xml__contains=[
'<instance id="choices">',
'<item>',
'<name>1</name>'
],
)
Currently, pyxform does not require labels for items in choice lists.
For dynamic selects, I can see an argument for them not being required because users could be building a list they only want to query and won't use in a select. However, I think that's pretty rare and for those advanced users, it's not a big deal to just add a label. In v1.4, if a user did build a dynamic select with a choice missing a label and used it in a select, there'd be a Validate error. In v1.5, there's a crash (narrowly addressed by #535).
For static selects, I don't see any use for a choice without a label. Currently there's no validation on this at all.
CC @MartijnR @pbowen-oc