How do I display every submission (i.e submission history) of a st.form instead of just the latest one?

I have a sample piece of code:

with st.form("my_form"):
            st.write("Inside the form")
            slider_val = st.slider("Form slider")
            checkbox_val = st.checkbox("Form checkbox")

            # Every form must have a submit button.
            submitted = st.form_submit_button("Submit")
            if submitted:
                st.write("slider", slider_val, "checkbox", checkbox_val)

I would ideally like that the ‘if submitted’ conditional will hold ALL submissions, instead of just the latest submission and overwriting the older submission. The purpose of this is so that I can display the history of submissions line by line, versus just the previous submission.

Thank you!

Hi @kantk2024

To achieve that, you may either have to append each submission to a list, you can leverage callback functions on the submit button to append the submission data to a list.

Instead of a list, you can also connect your app to a database (Connect to data sources - Streamlit Docs) and save those submissions there. A Google Sheets can also serve as the database.

Hope this helps!

Thank you! Appending to a list worked!

1 Like

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