Filter selectbox in st.form()

I’m running locally an app with streamlit 1.31.1. Up until last week i could dinamically filter selectboxes in an st.form() but now i can’t. Is there a secret form to do it now or a workaround?

    with st.form(key='elections_form'):
        anio_elecciones = st.selectbox(
            'Selecciona el año de la elección:',
            ('2011', '2015', '2019', '2023')
        )
        tipos = []
        if anio_elecciones == '2011' or anio_elecciones == '2019':
            tipos = ['PASO', 'GENERALES']
        elif anio_elecciones == '2015' or anio_elecciones == '2023':
            tipos = ['PASO', 'GENERALES', 'BALLOTAGE']
        tipo_elecciones = st.selectbox('Seleccione el tipo de elección:',tipos)
        third_options = ['RESULTADOS', 'CANDIDATOS', 'PARTICIPACION', 'VOTO EN BLANCO']
        selected_subcategory = st.selectbox('Seleccione la categoría', third_options)
        spacer(0.5)
        submit_button = st.form_submit_button(label='Visualizar')

this used to work

Interacting with a widget in a form has no effect in the application. The updated value won’t be available unitil the submit button is pressed. This is indeed the whole point of forms.

If you want the value of the widget to be available as soon as the user interact with it, then don’t put it in a form.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.