Module: RailsDataHelper

Defined in:
app/helpers/rails_data_helper.rb

Instance Method Summary collapse

Instance Method Details

#text_field_tag(name, value = nil, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/rails_data_helper.rb', line 3

def text_field_tag(name, value = nil, options = {})
  if options[:as]
    type = RailsData.config.mapping[options[:as]][:input]

    if type == 'textarea'
      return text_area_tag(name, value, options)
    end

    if type == 'select'
      opts = RailsData.config.mapping[options[:as]][:options]
      selected = RailsData.config.mapping[options[:as]][:selected]
      return select_tag name, options_for_select(opts, selected), options
    end
  end

  super
end