Using selectbox inside a form

Summary

My selectbox outside a form works (I mean : is recognized in my app) but in side a form, no value is recognized.

Steps to reproduce

Code snippet:

with st.form(key="my_form"):
                ingredientSelect = st.selectbox('Choisissez votre ingrédient',options=ingredients, key='ingredient_score', help="""Saisissez le maximum d'informations concernant le produit en question""")
                st.write("You selected : ", ingredientSelect)

Expected behavior:

I’d like to change the value of the selectbox and be recognized so it will change the rest of the form.

Actual behavior:


Here is the default value of my selectbox. But if I try to change the value :

Outside the form, it works like a charm !

Debug info

  • Streamlit version: 1.14.0
  • Python version: 3.9.13
  • Using Anaconda
  • OS version: Windows 10
  • Browser version: Chrome

The whole point of forms is not passing the values to python until the submit button is pressed. If you don’t want this, then don’t put the widget inside a form.

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