7
votes

I have the following simple_form input (HAML):

= congress_detail_form.input :stand_setup_time, as: :time

The as: :time part may be redundant as the database column type is TIME, which I think simple_form detects.

It defaults to the current time (it shows two selects, one for the hour, the other for the minute). I have been unable to set a default of 00:00 using default: or value:. Is this even possible?

I've been unable to find where in the simple_form codebase this default is set. Any help would be appreciated.

I've also found no timepicker that works with simple_form.

2

2 Answers

10
votes

i'm able to do this with default option:

= congress_detail_form.input :stand_setup_time, as: :time, default: Time.parse('8:00')
1
votes

I would say you setting default values to the instance variable in the controller.

Assuming you render your view from CongressesController:

class CongressesController < ApplicationController
  ...
  def new
    @congress_detail = CongressDetail.new(stand_setup_time: Time.parse('00:00'))
  end
  ...
end

It allows you to have your views smaller and clearer. And that's how you should keep them =)