Sha256: 80cfb665d2bb4e49f4d5ac1c2e67031bd62610ef66f6d42746a6bd30a6323641

Contents?: true

Size: 1.83 KB

Versions: 7

Compression:

Stored size: 1.83 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 documentation of all possible options.
    #
    # The priority_zones option:
    #   Since this input actually uses Rails' `time_zone_select` helper, the :priority_zones
    #   option needs to be an array of ActiveSupport::TimeZone objects.
    #
    #   And you can configure default value using
    #
    #   ```
    #     Formtastic::FormBuilder.priority_time_zones = [timezone1, timezone2]
    #   ```
    #
    #   See http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/time_zone_select for more information.
    #
    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] || Formtastic::FormBuilder.priority_time_zones
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/lib/formtastic/inputs/time_zone_input.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/lib/formtastic/inputs/time_zone_input.rb
formtastic-4.0.0 lib/formtastic/inputs/time_zone_input.rb
formtastic-4.0.0.rc1 lib/formtastic/inputs/time_zone_input.rb
formtastic-3.1.5 lib/formtastic/inputs/time_zone_input.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/formtastic-3.1.4/lib/formtastic/inputs/time_zone_input.rb
formtastic-3.1.4 lib/formtastic/inputs/time_zone_input.rb