Sha256: cabd70e5e6131228bce3ccb106de9d5d976eae8015ef59e6afe2cd28303cf1b2

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 KB

Contents

module Formtastic
  module Inputs

    # Outputs a `<label>` with a `<select>` containing a series of time zones (using Rails' own
    # `time_zone_select` helper), wrapped in the standard `<li>` wrapper.

    # This is the default input choice for attributes matching /time_zone/, but can be applied to
    # any text-like input with `:as => :time_zone`.
    #
    # @example Full form context and output
    #
    #   <%= semantic_form_for(@user) do |f| %>
    #     <%= f.inputs do %>
    #       <%= f.input :time_zone, :as => :time_zone %>
    #     <% end %>
    #   <% end %>
    #
    #   <form...>
    #     <fieldset>
    #       <ol>
    #         <li class="time_zone">
    #           <label for="user_time_zone">Time zone</label>
    #           <input type="text" id="user_time_zone" name="user[time_zone]">
    #         </li>
    #       </ol>
    #     </fieldset>
    #   </form>
    #
    # @see Formtastic::Helpers::InputsHelper#input InputsHelper#input for full documetation of all possible options.
    #
    # @todo document :priority_zones option
    # @todo configurable default :priority_zones?
    class TimeZoneInput 
      include Base

      def to_html
        input_wrapping do
          label_html <<
          builder.time_zone_select(method, priority_zones, input_options, input_html_options)
        end
      end
      
      def priority_zones
        options[:priority_zones] || [] # TODO config?
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
formtastic-2.0.2 lib/formtastic/inputs/time_zone_input.rb
formtastic-2.0.1 lib/formtastic/inputs/time_zone_input.rb
formtastic-2.0.0 lib/formtastic/inputs/time_zone_input.rb
formtastic-2.0.0.rc5 lib/formtastic/inputs/time_zone_input.rb
formtastic-2.0.0.rc4 lib/formtastic/inputs/time_zone_input.rb
formtastic-2.0.0.rc3 lib/formtastic/inputs/time_zone_input.rb
formtastic-2.0.0.rc2 lib/formtastic/inputs/time_zone_input.rb
formtastic-2.0.0.rc1 lib/formtastic/inputs/time_zone_input.rb
nuatt-formtastic-0.2.3 lib/formtastic/inputs/time_zone_input.rb