Form elements can't get new values

Environment: Mac/M1, chrome, streamlit 0.85.1

with st.form(key="update_status"):
            selected_code = st.selectbox('select code', df["code"].tolist())
            selected_status = st.selectbox('select status', status)
            btn = st.form_submit_button('submit')
            print(btn)
            if not btn:
                submit_status(selected_code, selected_status)

I found two issues not complied with the document:

  1. if I use “on_click” to call submit function, two select values can’t be updated
  2. if I use return value of submit button to call it, return bool value is oppsite to common sense. Only like my code, the evnent to click button can be invoked.

I don’t understand how to create a form in streamlit acting like other web forms. Is it because of document or bugs in code?

Thanks joe. I tried the way you mentioned that caused the same result. But I did find out why just now.

There’s a button to load the whole UI manually in the code. When I move this function to the root of code that resolves the problems above. I guess streamlit using “reload the whole page” to pass params to submit function. This design idea blows my mind. :man_shrugging:

1 Like

I saw your post before, but I don’t recomend you to take time on it. IMHO, streamlit is only appropriate to the single page for ML charting and it’ll reload the whole page on any trivia change. It’s better for you to find another solution even Google Docs.