Class: DatePairInput

Inherits:
SimpleForm::Inputs::Base
  • Object
show all
Defined in:
app/inputs/date_pair_input.rb

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Direct Known Subclasses

DatetimePairInput

Instance Method Summary collapse

Instance Method Details

#input(wrapper_options) ⇒ Object

Output two date fields: start and end




11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/inputs/date_pair_input.rb', line 11

def input(wrapper_options)
  add_autocomplete!
  out = "<br />".html_safe

  field1, field2 = get_fields

  [field1, field2].compact.each do |field|
    out << '<div>'.html_safe
    label = field == field1 ? I18n.t('pair.start') : I18n.t('pair.end')
    %i[required disabled].each { |k| input_html_options.delete(k) } # ensure these come from field not default options
    input_html_options.merge!(field.input_options)
    input_html_options[:value] = value(field)
    out << "<label#{' class="req"' if input_html_options[:required]}>#{label}</label>".html_safe
    text = @builder.text_field(field.name, merge_wrapper_options(input_html_options, wrapper_options))
    out << text << '</div>'.html_safe
  end

  out
end