Skip to content

How to refer to checklist value #1362

Answered by mturoci
gbethardy-h2oai asked this question in Q&A
Discussion options

You must be logged in to vote

Checklist is for gathering multiple selections, for single selections you might want to use checkbox instead. Maybe you are looking for something like:

@app('/demo')
async def serve(q: Q):
    if not q.client.initialized or q.args.show_form:
        q.page['example'] = ui.form_card(box='1 1 4 10', items=[
            ui.checklist(name='checklist', label='Choices',
                         choices=[ui.choice(name=x, label=x) for x in ['Egg', 'Bacon', 'Spam']]),
            ui.button(name='show_inputs', label='Submit', primary=True),
        ])
        q.client.initialized = True
    # Check if specified item is selected.
    if q.args.checklist and 'Egg' in q.args.checklist:
        q.page['…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@gbethardy-h2oai
Comment options

@mturoci
Comment options

@gbethardy-h2oai
Comment options

Answer selected by mturoci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants