I just started using st.form , I did not find this question anywhere. Please bear with me.
This is my code.
with st.form('form1'):
parameter1 , parameter2 = st.columns(2)
with parameter1:
grps = ['ABC','DEF']
grp= st.selectbox('Account',grps )
with parameter2:
if grp == 'ABC':
items = ['ABC1','ABC2','ABC3']
else:
items = ['DEF1','DEF2']
items = st.multiselect('Items',items)
submit_form = st.form_submit_button('Submit')
st.write(grp,items)
When I select the first select box to DEF , it should automatically pick the next multiselect based upon the first variable value but here it is not considering the grp input.
It is still showing ABC1 , ABC2 , ABc3 values , even if I select DEF grp.
when I hit submit , it is only displaying the grp value but not the multi select one.
Hi @Santosh, A form is meant to batch-process inputs; if you have conditional logic for any widget, dont put those widgets in a form. Check your revised code below:
Thanks! @gaganmanku96. I was thinking since since Streamlit runs from top to bottom inside the forms.
So I thought it would pass the first input widget value to the second input widget. Well a good thing to know
Thanks! @Shawn_Pereira. I’m trying to create a operational report so form is much needed for me. I’ll do some trial and error methods and post it here if I found any work around