Initialization of data_input


Hi, I want to check if a data_input has been selected within a form.
curerent date is displayed automatically

In order to check, if value was explicitly I added value=None

However, even when I do not touch the date picker, the value is always todays date.

Steps to reproduce

Code snippet:

with st.form("add_user", clear_on_submit=False):
#...other code
  birthDate = st.date_input("Geburtsdatum", value=None,, 2, 1),     format='DD/MM/YYYY', key='birthDate')
  entryDate = st.date_input("Eintrittsdatum", value=None, format='DD/MM/YYYY', key='entryDate')
#...othe code
if submitted:
      st.write(f'"BD: " {birthDate} ", ED: " {entryDate}')
      if birthDate is None or entryDate isNone:
         st.error("All fields must be edited")

Expected behavior:

In this case output

Actual behavior:

Output is current date and error message does not appear

Expected behavior:

Output is none and error message appears

Debug info

  • Streamlit version: 1.26.0
  • Python version: 3.10.12
  • Using Conda
  • OS version: MacOS
  • Browser version: all

The ability to initialize st.date_input() with None was added in version 1.27.0.

…interesting that the version before accepts this attribute without error

It is not an error but it has a different meaning.

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