patrickdm
Phoenix.HTML.Form.date_select/3 with null default value
Hello,
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.
Marked As Solved
kokolegorille
I use date_select with null default value like this.
<%=
date_select f,
:expiry_date,
year: [prompt: ""],
month: [prompt: ""],
day: [prompt: ""],
class: "form-control"
%>
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









