Skip to content

Custom inputs examples

donapieppo edited this page Nov 14, 2012 · 2 revisions

Week Day Input

In order to get an input with localized week days:

# app/inputs/wday_input.rb 
class WdayInput < SimpleForm::Inputs::Base
  def input
    @builder.select(attribute_name, I18n.t(:"date.day_names").each_with_index.to_a)
  end 
end

Then, use it in your form:

<%= timetable.input :wday, :as => :wday %>

Clone this wiki locally