Phoenix.HTML.Form.date_select/3 with null default value

I have a resource’s date-field which is optional (so in most records it has a null value) and in the form I render it with date_select/3 (datetime_select/3 for options and supported values)

When I edit a record with a null date-field, date_select displays 2015/01/01 as default value for it.

This date value is then stored on update, along with the actual record’s field I was actually editing.

I tried using the option default: nil in order to avoid the date-field to be updated too, with no success.

I’m bypassing this issue using a text_input/3 field in place of date_select/3, but still wondering if I’m just missing the simple/obvious solution, which I presume is hidden in plain sight to my eyes.

Thank you for any suggestion and help.

1 Like

I use date_select with null default value like this.

      date_select f, 
        year: [prompt: ""], 
        month: [prompt: ""], 
        day: [prompt: ""],
        class: "form-control" 

Thank you very much, this is exactly what I was aiming for, but couldn’t find the right spell.