Sha256: 76c2096d13ba8fcc268e2584398fb60d239125dd9179ae716edca2d616b60d9e

Contents?: true

Size: 985 Bytes

Versions: 25

Compression:

Stored size: 985 Bytes

Contents

module Formtastic
  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 
      include Base
      include Base::Timeish
      
      # We don't want hour and minute fragments on a date input
      def time_fragments
        []
      end
      
      def hidden_date_fragments
        default_date_fragments - date_fragments
      end

      def hidden_fragments
        hidden_date_fragments.map do |fragment|
          template.hidden_field_tag(hidden_field_name(fragment), fragment_value(fragment), :id => fragment_id(fragment), :disabled => input_html_options[:disabled] )
        end.join.html_safe
      end

      def fragment_value(fragment)
        if fragment == :year
          Time.now.year
        else
          '1'
        end
      end      
    end
  end
end

Version data entries

25 entries across 25 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/date_select_input.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/lib/formtastic/inputs/date_select_input.rb
formtastic-4.0.0 lib/formtastic/inputs/date_select_input.rb
formtastic-4.0.0.rc1 lib/formtastic/inputs/date_select_input.rb
formtastic-3.1.5 lib/formtastic/inputs/date_select_input.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/formtastic-3.1.4/lib/formtastic/inputs/date_select_input.rb
formtastic-3.1.4 lib/formtastic/inputs/date_select_input.rb
formtastic-3.1.3 lib/formtastic/inputs/date_select_input.rb
formtastic-3.1.2 lib/formtastic/inputs/date_select_input.rb
formtastic-3.1.1 lib/formtastic/inputs/date_select_input.rb
formtastic-3.1.0 lib/formtastic/inputs/date_select_input.rb
formtastic-3.1.0.rc2 lib/formtastic/inputs/date_select_input.rb
formtastic-3.1.0.rc1 lib/formtastic/inputs/date_select_input.rb
formtastic-3.0.0 lib/formtastic/inputs/date_select_input.rb
formtastic-3.0.0.rc2 lib/formtastic/inputs/date_select_input.rb
formtastic-2.3.1 lib/formtastic/inputs/date_select_input.rb
formtastic-2.3.0 lib/formtastic/inputs/date_select_input.rb
formtastic-3.0.0.rc lib/formtastic/inputs/date_select_input.rb
formtastic-2.3.0.rc4 lib/formtastic/inputs/date_select_input.rb
formtastic-2.3.0.rc3 lib/formtastic/inputs/date_select_input.rb