Skip to content

Expander inside Form raises Missing Submit Button #4531

@H4dr1en

Description

@H4dr1en

Summary

st.expander inside st.form raises Missing Submit Button when folded

Steps to reproduce

Code snippet:

import streamlit as st

with st.form("my_form"):
    with st.expander("test expander"):
        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)

st.write("Outside the form")

Expected behavior:

No bug

Actual behavior:

The following error is raised:

Missing Submit Button

This form has no submit button, which means that user interactions will never be sent to your Streamlit app.

To create a submit button, use the st.form_submit_button() function.

For more information, refer to the [documentation for forms](https://docs.streamlit.io/library/api-reference/control-flow/st.form).

Is this a regression?

That is, did this use to work the way you expected in the past?
No

Debug info

  • Streamlit version: (get it with $ streamlit version) 1.7.0
  • Python version: (get it with $ python --version) 3.6.0
  • Using Conda? PipEnv? PyEnv? Pex? Conda
  • OS version: macOS 12.2.1
  • Browser version: Firefox 98.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions