Hi I have encountered an error where you cannot specify another key for the form widgets.
Here is the method I use to generate keys for the form widgets which works on all other streamlit widgets I used in my application
Hi I have encountered an error where you cannot specify another key for the form widgets.
Here is the method I use to generate keys for the form widgets which works on all other streamlit widgets I used in my application
You can provide only one key. Why do you want to give two keys to the same form?
Hey @luqmannur.ai!
I understand the confusion, a lot of Streamlit commands have arguments label
and key
… but st.form()
doesn’t have any label
! In fact, key
is a positional argument in st.form()
, and is even the very first argument that is expected.
Meaning whenever you call st.form("Chat Feedback")
, this is understood as calling st.form(key="Chat Feedback")
! So using st.form("Chat Feedback", key=form_key)
throws an exception because it is understood as st.form(key="Chat Feedback", key=form_key)
Probably if you are creating multiple forms and want to make sure keys don’t collide, you may want to switch your code to simply be:
with st.form(form_key):
st.write("Feedback form")
...
Hope that helps
Hi arnaud, thanks for the reply and helping a new learner out.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.