Module: JqueryUiForm::Helpers::InputHelper

Included in:
FormBuilder
Defined in:
lib/jquery_ui_form/helpers/input_helper.rb

Instance Method Summary collapse

Instance Method Details

#basic_input_helper(form_helper_method, type, method, options) ⇒ Object

:nodoc:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/jquery_ui_form/helpers/input_helper.rb', line 31

def basic_input_helper(form_helper_method, type, method, options) #:nodoc:
  label_options = options.delete(:html_label) || {}
  label_options[:required] = options[:required]
  label_options[:label] = options.delete(:label)
  hint = options[:placeholder] = options.delete(:hint)
  if options.delete(:no_label) 
    "".html_safe
  else
    label(method, label_options)
  end <<
  send(respond_to?(form_helper_method) ? form_helper_method : :text_field, method, options) <<
  inline_hint(hint, type) <<
  inline_error(method)
end

#inline_hint(hint, type = nil) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/jquery_ui_form/helpers/input_helper.rb', line 46

def inline_hint(hint, type = nil)
  return "" if hint.blank?
  if use_i18n
    hint = I18n.t(hint,:scope => [:helpers, :hints])
  end
  return "" if html5_inputs && placeholder_elements.include?(type.to_s)
  template.(:div, hint, :class => "ui-input-hint")
end

#input(method, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/jquery_ui_form/helpers/input_helper.rb', line 5

def input(method, options={})
  row_options = options.delete(:html_row) || {}
  
  options[:as] ||= default_input_type(method, options)
  
  row_options[:class] ||= ""
  row_options[:class] << " ui-#{options[:as]}-input"
  
  options[:class] ||= ""
  options[:class] << " ui-#{options[:as]}-input"
  
  if options[:as] == :hidden
    return send(:"#{options.delete(:as)}_input", method, options)
  end
  
  options[:required] = method_required?(method) if options[:required].nil?
  options[:class] << " ui-input-error" if has_errors?(method)
  if (@template.autofocus) && options[:as] != :hidden
    options[:autofocus] = true 
    @template.autofocus = false
  end
  column(row_options) do
    send(:"#{options.delete(:as)}_input", method, options)
  end
end