Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added country and date_select inputs

  • Loading branch information...
commit 45252a759b8d5ff4eb875dfcc74fe020c3d22cdf 1 parent c27667e
@d3chapma d3chapma authored
View
2  lib/formtastic-bootstrap/inputs.rb
@@ -1,7 +1,9 @@
require "formtastic-bootstrap/inputs/base"
require "formtastic-bootstrap/inputs/boolean_input"
require "formtastic-bootstrap/inputs/check_boxes_input"
+require "formtastic-bootstrap/inputs/country_input"
require "formtastic-bootstrap/inputs/date_input"
+require "formtastic-bootstrap/inputs/date_select_input"
require "formtastic-bootstrap/inputs/datetime_input"
require "formtastic-bootstrap/inputs/email_input"
require "formtastic-bootstrap/inputs/file_input"
View
13 lib/formtastic-bootstrap/inputs/base/timeish.rb
@@ -5,21 +5,18 @@ module Timeish
def date_input_html
fragment_input_html(:date, "small")
- end
- def time_input_html
- fragment_input_html(:time, "mini")
end
- def fragment_id(fragment)
- # TODO is this right?
- # "#{input_html_options[:id]}_#{position(fragment)}i"
- "#{input_html_options[:id]}[#{fragment}]"
+ def time_input_html
+ default_date_fragments.map do |fragment|
+ fragment_input_html(:time, "mini")
+ end.join.html_safe
end
def fragment_input_html(fragment, klass)
opts = input_options.merge(:prefix => fragment_prefix, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
- template.send(:"text_field_#{fragment}", value, opts, input_html_options.merge(:id => fragment_id(fragment), :class => klass))
+ template.send(:"select_#{fragment}", value, opts, input_html_options.merge(:id => fragment_id(fragment), :class => klass))
end
end
View
12 lib/formtastic-bootstrap/inputs/country_input.rb
@@ -0,0 +1,12 @@
+module FormtasticBootstrap
+ module Inputs
+ class CountryInput < Formtastic::Inputs::CountryInput
+ include Base
+ def to_html
+ generic_input_wrapping do
+ builder.country_select(method, priority_countries, input_options, input_html_options)
+ end
+ end
+ end
+ end
+end
View
18 lib/formtastic-bootstrap/inputs/date_select_input.rb
@@ -0,0 +1,18 @@
+module FormtasticBootstrap
+ module Inputs
+ # Outputs a series of select boxes for the fragments that make up a date (year, month, day).
+ #
+ # @see Formtastic::Inputs::Base::Timeish Timeish module for documentation of date, time and datetime input options.
+ class DateSelectInput < Formtastic::Inputs::DateInput
+ include Base
+ include Base::Stringish
+ include Base::Timeish
+
+ def to_html
+ generic_input_wrapping do
+ date_input_html
+ end
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.