0
@@ -69,6 +69,7 @@ module JustinFrench #:nodoc:
0
# * :datetime (a date and time select) - default for :datetime and :timestamp column types
0
# * :time (a time select) - default for :time column types
0
# * :boolean (a checkbox) - default for :boolean column types
0
+ # * :boolean_select (a yes/no select box)
0
# * :string (a text field) - default for :string column types
0
# * :numeric (a text field, like string) - default for :integer, :float and :decimal column types
0
@@ -357,16 +358,29 @@ module JustinFrench #:nodoc:
0
- # Outputs a label containing a checkbox and the label text.
0
- # TODO - what about a yes/no boolean?
0
+ # Outputs a label containing a checkbox and the label text. The label defaults to the column
0
+ # name (method name) and can be altered with the :label option.
0
def boolean_input(method, options)
0
input_label(method, options,
0
@template.check_box(@object_name, method) +
0
label_text(method, options)
0
+ # Outputs a label and select box containing two options for "true" and "false". The visible
0
+ # text defaults to "Yes" and "No" respectively, but can be altered with the :true and :false
0
+ # options. The label text to the column name (method name), but can be altered with the
0
+ # :label option. Example:
0
+ # f.input :awesome, :as => :boolean_select, :true => "Yeah!", :false => "Nah!", :label => "Awesome?"
0
+ def boolean_select_input(method, options)
0
+ options[:true] ||= "Yes"
0
+ options[:false] ||= "No"
0
+ choices = [ [options[:true],1], [options[:false],0] ]
0
+ input_label(method, options) + @template.select(@object_name, method, choices)
0
def inline_errors(method, options) #:nodoc:
0
errors = @template.instance_eval("@#{@object_name}").errors.on(method).to_a
0
errors.empty? ? '' : @template.content_tag(:p, errors.to_sentence, :class => 'inline-errors')
Comments
No one has commented yet.