Struggling with states and forms - multiple variable number of them!

Hi there

I am working on a small NLP UI where I would like to generate (and possibly) change parts of the text dynamically.
Each part is associated with a form and its submit_form_button using the following code:

        form3 = [st.form(key=f"form3_{i}") for i in range(len(lines))]
        for i, line in enumerate(lines):
            with form3[i]:
                _ = st.text_area(f"{line}", st.session_state.part3[line]["data"], 200)
                if form3[i].form_submit_button("Change"):
                    st.session_state.part3[line]["data"] = _part3()

When I play with the buttons, the click (in any of the form) does not change anything the following work fine but if I move to a different form then the first click does not apply to the new form but the previous one.

I am banging my head on the walls :slight_smile:
I got inspired by some posts in this forum for managing the state of the UI but I am open to any suggestion
The app is here and the code there

Thanks for your help !

Oh i think I have finally understood … when I click on the “Change” button my content get changed but my UI is not refreshed. I need now to figure how to do that !

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