My Streamlit app uses a form to get feedback from a user. The questions are taken from a pandas dataframe, and when the user click’s Submit , the questions plus responses are stored in a list that is preserved using st.session_state.
There is an interesting problem that has emerged. When using forms, the user responses don’t get assigned to their variables (e.g. question1 = text_input()) until after a user submits. But, the question that the user is seeing on their screen will reset when the user hits submit, so there’s a hard to see problem: When you append the question/response to a list, it’s the wrong question . The reason is that when you hit ‘submit’ the script reruns, and therefore a new question from the dataframe is grabbed and saved with the responses.
Does anyone know a way around this problem?