Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require labels for items in choice lists #534

Open
lognaturel opened this issue Apr 22, 2021 · 3 comments
Open

Require labels for items in choice lists #534

lognaturel opened this issue Apr 22, 2021 · 3 comments
Milestone

Comments

@lognaturel
Copy link
Contributor

lognaturel commented Apr 22, 2021

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>'
            ],
        )
@lognaturel
Copy link
Contributor Author

@lindsay-stevens could you please briefly look into how this intersects with #679? Should we close this?

@lognaturel lognaturel added this to the Next milestone Feb 20, 2024
@tiritea
Copy link

tiritea commented Nov 4, 2024

what about image-only selections?

https://docs.getodk.org/form-question-types/#select-from-image-widget
or
https://docs.getodk.org/form-question-types/#select-one-from-map-widget

There's probably no particular harm in requiring the form designer to always add a text label to everything - even if the appearance may hide them. But making them mandatory may result in the inability to prevent any text being displayed should they desire a purely pictorial interface for the selection (for whatever reason...); eg I dont think you can otherwise hide the label being shown for a map.

@lindsay-stevens
Copy link
Contributor

Maybe this could be thought of as "if the XForm result for this choice is going to be empty itext then raise an error" e.g. either a label, or a translation, or some kind of media.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants