module ExtForm::Helpers::FormTagHelper

Public Instance Methods

auto_complete_tag(name, value, options={}) click to toggle source

JS auto complete feature using twitter typeahead.js, pass options through data. see: ExtForm::Helpers::FormHelper#auto_complete TODO: this feature needs to be tested.

# File lib/ext_form/helpers/form_tag_helper.rb, line 46
def auto_complete_tag(name, value, options={})
  id = sanitize_to_id(name)
  default_options = {id: id}
  options.reverse_merge!(default_options)

  output = text_field_tag(name, value, options)
  output << javascript_tag do
    "$('##{options[:id]}').trigger('auto_complete_load');".html_safe
  end

  output.html_safe
end
dt_picker_tag(name, value, options={}) click to toggle source

Datetime picker tag helper, based on bootstrap-datetimepicker

object_name - the object name of form builder method - method of object options - all options are as same as text field.

data -
  format      - yyyy-mm-dd, yyyy/mm/dd.....
  week_start  - 0-6
  start_date  - can't pick the date before the start_date.
  end_date    - can't pick the date after the end_date.
  view_mode   - 0..month,1..year,2..10 years
  min_view_mode   - not be tested....
  language    - default pt-BR, see bootstrap-datetimepicker API
  mask_input  - true, false disables the text input mask
  pick_date   - true, false disables the date picker
  pick_time   - true, false disables de time picker
  pick_12_hour_format - false, true enables the 12-hour format time picker
  pick_seconds        - true
# File lib/ext_form/helpers/form_tag_helper.rb, line 24
def dt_picker_tag(name, value, options={})
  id = sanitize_to_id(name)
  default_options = {id: id}
  options.reverse_merge!(default_options)

  output = content_tag(:div, nil, class: 'input-append') do
    [text_field_tag(name, value, options),
     content_tag(:span, nil, class: 'add-on') do
       content_tag(:i, nil, data: {date_icon: 'icon-calendar', time_icon: 'icon-time'})
     end
    ].join.html_safe
  end
  output << javascript_tag do
    "$('##{options[:id]}').trigger('dt_picker_load');".html_safe
  end

  output.html_safe
end