Thanks to visit codestin.com
Credit goes to github.com

Skip to content

st.multiselect returns empty on dynamically changing options.  #7855

@PradeepReddy-epi

Description

@PradeepReddy-epi

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Streamlit multi_select element st.multi_select not working as expected inside streamlit form st.form. After selecting multiple options through the multi select element, on form submission, the multiselect widget giving empty value [].

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st

with st.form(key="async_testing_config"):
        # Components : Select async api endpoints for testing.
        components = st.multiselect(
            "Select async api endpoints",
           external_call_to_aws_api_to_get_list_of_endpoints(),
            key="components"
        )

        # Submitted - BOOLEAN
        Submitted = st.form_submit_button("Submit")
        if Submitted:
            print("project id: ", project_id)
            print("endpoints: ",components)

Steps To Reproduce

No response

Expected Behavior

After submitting the form, user should be able to get all options selected through multi select widget.

Current Behavior

User getting empty value after submitting. Note: the options passed to the multiselect widget is an external api call to aws api to list of endpoints (options). I tried with streamlit version 1.28.2 and also latest version 1.29.0 as well, facing the same issue.

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.28.2
  • Python version: 3.9
  • Operating System: Mac
  • Browser: Chrome

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.formRelated to the `st.form` containerfeature:st.multiselectRelated to the `st.multiselect` widgettype:enhancementRequests for feature enhancements or new features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions