How can I give a text input a default value in Elixir/Phoenix?

Viewed 762

I have this field

  <%= number_input f, :duration_minutes %>

and I would like to give it a default of 60. How can I do that?

The obvious guess of

  <%= number_input f, :duration_minutes, default: 60 %>

didn't work.

1 Answers

Update based on the comment from Allen:

  schema "events" do
    field :duration_minutes, :integer, default: 60
  end

Here is my previous answer that isn't as robust according to him:

  <%= number_input f, :duration_minutes, value: 60 %>
Related