Optional date input in Phoenix date_select

Hello, I want to allow my user to leave the date_select input blank and it will default to a date of my choosing (I will handle this in controller). However; the current behavior is that it if the user does not pass anything it will not pass the date in the params, or if the user passes in only the year; it will only pass in the year in the params.

The following is my function.

          <%= label f, :date %>
          <%= date_select f, :date, year: [options: 2020..2022, prompt: "", autocomplete: "off"], month: [prompt: "month", autocomplete: "off"], day: [prompt: "day", autocomplete: "off"] %>

Thank you.

This is the top of my form in case it carries any significance.

  <%= form_for :export, Routes.path(Web.Endpoint, :export, @ticket), [method: :get], fn f -> %>

PS. Do you know if there’s a way to make each date field required - e.g. year, month, day?

Isn’t it simpler to provide a default value of your choice?

Otherwise You could add this value on the backend, by setting this field if nil in the params.