EEX Datetime Select in Form

Hi I’m trying to place a Datetime select field (EEx) however it doesn’t work:

<label>DateTime:<%= datetime_select f, :born_at, :default %></label></br>

This error is shown:

no function clause matching in Keyword.get/3

The third argument to datetime_select/3 is supposed to be a keyword list. You’re passing it the atom :default.

Do you have a working example?

The third one you mean, I think…

Its in the docs:

Changed to this, but i keep getting the error:

<label>DateTime:<%= datetime_select f, :born_at, year: [options: 1900..2100] %></label></br>
argument error
1194    {value, opts} = Keyword.pop(opts, :options, values)
1196    {value,
1197      opts
1198      |> Keyword.put_new(:id, id <> "_" <> suff)

Are you using the form_for/3,4 on @conn? If so, I reproduced your issue and solved it by filling :as in the third argument of form_for/4:

<%= form_for @conn, page_path(@conn, :index), [as: "test"], fn f -> %>
  <%= datetime_select f, :born_at, year: [options: 1900..2100] %>
<% end %>

If that’s not the case, please go ahead and post your template so we can try to reproduce the error.

If it’s similar to what I have above - your %Phoenix.HTML.Form{} struct has %...{... id: nil} which causes nil to be concatenated with a string which Elixir says is a no no!



The as: parameter solved the issue!