Re render form on button click

def main():
    st.title("Guess name")
    release_name_form = st.form(key="Input name")
    name = release_name_form.text_input("Name", "")
    guess_clicked = release_name_form.form_submit_button("Guess Data")

    if guess_clicked:
        with st.form(key="test"):
            col1, col2 = st.columns(2)
            col1.text_input("Firstname", name.split()[0])
            col2.text_input("Lastname", name.split()[-1])
            submit = st.form_submit_button("Submit")

Hi wrote a simple program to type in a full name and then use split to display first and last name using text input so users can edit it and submit it

Lets say a user changed the data in the col1 aka Firstname field unintentionally.

When the user clicks guess Data / guess_clicked button the st.form(key="test") fields don’t refresh

only when the data in release_name_form = st.form(key="Input name") changes the second form re renders

how can I get the second form to re render on the guess_clicked button click ?

I guess a form of reset form button work too. But not sure how i can implement that. There is a clear on submit but no reset option in st.form

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