formtastic 1.2.5 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/.gitignore +13 -0
  2. data/.rspec +2 -0
  3. data/.yardopts +1 -0
  4. data/CHANGELOG +279 -0
  5. data/Gemfile +3 -0
  6. data/README.textile +155 -172
  7. data/RELEASE_PROCESS +7 -0
  8. data/Rakefile +52 -0
  9. data/app/assets/stylesheets/formtastic.css +275 -0
  10. data/app/assets/stylesheets/formtastic_ie6.css +27 -0
  11. data/app/assets/stylesheets/formtastic_ie7.css +17 -0
  12. data/formtastic.gemspec +51 -0
  13. data/lib/formtastic.rb +21 -1960
  14. data/lib/formtastic/engine.rb +7 -0
  15. data/lib/formtastic/form_builder.rb +83 -0
  16. data/lib/formtastic/helpers.rb +16 -0
  17. data/lib/formtastic/helpers/buttons_helper.rb +277 -0
  18. data/lib/formtastic/helpers/errors_helper.rb +113 -0
  19. data/lib/formtastic/helpers/fieldset_wrapper.rb +75 -0
  20. data/lib/formtastic/helpers/file_column_detection.rb +16 -0
  21. data/lib/formtastic/helpers/form_helper.rb +198 -0
  22. data/lib/formtastic/helpers/input_helper.rb +366 -0
  23. data/lib/formtastic/helpers/inputs_helper.rb +392 -0
  24. data/lib/formtastic/helpers/reflection.rb +33 -0
  25. data/lib/formtastic/helpers/semantic_form_helper.rb +11 -0
  26. data/lib/formtastic/html_attributes.rb +21 -0
  27. data/lib/formtastic/i18n.rb +1 -0
  28. data/lib/formtastic/inputs.rb +31 -0
  29. data/lib/formtastic/inputs/base.rb +61 -0
  30. data/lib/formtastic/inputs/base/associations.rb +31 -0
  31. data/lib/formtastic/inputs/base/choices.rb +103 -0
  32. data/lib/formtastic/inputs/base/collections.rb +94 -0
  33. data/lib/formtastic/inputs/base/database.rb +17 -0
  34. data/lib/formtastic/inputs/base/errors.rb +58 -0
  35. data/lib/formtastic/inputs/base/fileish.rb +23 -0
  36. data/lib/formtastic/inputs/base/grouped_collections.rb +77 -0
  37. data/lib/formtastic/inputs/base/hints.rb +31 -0
  38. data/lib/formtastic/inputs/base/html.rb +52 -0
  39. data/lib/formtastic/inputs/base/labelling.rb +55 -0
  40. data/lib/formtastic/inputs/base/naming.rb +42 -0
  41. data/lib/formtastic/inputs/base/options.rb +18 -0
  42. data/lib/formtastic/inputs/base/stringish.rb +35 -0
  43. data/lib/formtastic/inputs/base/timeish.rb +128 -0
  44. data/lib/formtastic/inputs/base/validations.rb +166 -0
  45. data/lib/formtastic/inputs/base/wrapping.rb +40 -0
  46. data/lib/formtastic/inputs/boolean_input.rb +96 -0
  47. data/lib/formtastic/inputs/check_boxes_input.rb +179 -0
  48. data/lib/formtastic/inputs/country_input.rb +66 -0
  49. data/lib/formtastic/inputs/date_input.rb +14 -0
  50. data/lib/formtastic/inputs/datetime_input.rb +9 -0
  51. data/lib/formtastic/inputs/email_input.rb +40 -0
  52. data/lib/formtastic/inputs/file_input.rb +42 -0
  53. data/lib/formtastic/inputs/hidden_input.rb +66 -0
  54. data/lib/formtastic/inputs/number_input.rb +118 -0
  55. data/lib/formtastic/inputs/numeric_input.rb +21 -0
  56. data/lib/formtastic/inputs/password_input.rb +40 -0
  57. data/lib/formtastic/inputs/phone_input.rb +41 -0
  58. data/lib/formtastic/inputs/radio_input.rb +157 -0
  59. data/lib/formtastic/inputs/range_input.rb +119 -0
  60. data/lib/formtastic/inputs/search_input.rb +40 -0
  61. data/lib/formtastic/inputs/select_input.rb +210 -0
  62. data/lib/formtastic/inputs/string_input.rb +34 -0
  63. data/lib/formtastic/inputs/text_input.rb +47 -0
  64. data/lib/formtastic/inputs/time_input.rb +14 -0
  65. data/lib/formtastic/inputs/time_zone_input.rb +48 -0
  66. data/lib/formtastic/inputs/url_input.rb +40 -0
  67. data/lib/formtastic/localized_string.rb +105 -0
  68. data/lib/formtastic/railtie.rb +5 -7
  69. data/lib/formtastic/semantic_form_builder.rb +11 -0
  70. data/lib/formtastic/util.rb +6 -19
  71. data/lib/formtastic/version.rb +3 -0
  72. data/lib/generators/formtastic/install/install_generator.rb +28 -6
  73. data/lib/generators/templates/_form.html.erb +10 -4
  74. data/lib/generators/templates/_form.html.haml +8 -4
  75. data/lib/generators/templates/formtastic.rb +25 -32
  76. data/lib/locale/en.yml +1 -0
  77. data/lib/tasks/verify_rcov.rb +44 -0
  78. data/sample/basic_inputs.html +182 -0
  79. data/sample/config.ru +69 -0
  80. data/sample/index.html +14 -0
  81. data/spec/builder/custom_builder_spec.rb +109 -0
  82. data/spec/builder/error_proc_spec.rb +27 -0
  83. data/spec/builder/errors_spec.rb +193 -0
  84. data/spec/builder/semantic_fields_for_spec.rb +88 -0
  85. data/spec/helpers/buttons_helper_spec.rb +150 -0
  86. data/spec/helpers/commit_button_helper_spec.rb +470 -0
  87. data/spec/helpers/form_helper_spec.rb +135 -0
  88. data/spec/helpers/input_helper_spec.rb +837 -0
  89. data/spec/helpers/inputs_helper_spec.rb +562 -0
  90. data/spec/helpers/semantic_errors_helper_spec.rb +112 -0
  91. data/spec/i18n_spec.rb +199 -0
  92. data/spec/inputs/boolean_input_spec.rb +184 -0
  93. data/spec/inputs/check_boxes_input_spec.rb +375 -0
  94. data/spec/inputs/country_input_spec.rb +133 -0
  95. data/spec/inputs/custom_input_spec.rb +52 -0
  96. data/spec/inputs/date_input_spec.rb +110 -0
  97. data/spec/inputs/datetime_input_spec.rb +115 -0
  98. data/spec/inputs/email_input_spec.rb +55 -0
  99. data/spec/inputs/file_input_spec.rb +59 -0
  100. data/spec/inputs/hidden_input_spec.rb +120 -0
  101. data/spec/inputs/include_blank_spec.rb +70 -0
  102. data/spec/inputs/label_spec.rb +104 -0
  103. data/spec/inputs/number_input_spec.rb +487 -0
  104. data/spec/inputs/numeric_input_spec.rb +41 -0
  105. data/spec/inputs/password_input_spec.rb +69 -0
  106. data/spec/inputs/phone_input_spec.rb +55 -0
  107. data/spec/inputs/placeholder_spec.rb +71 -0
  108. data/spec/inputs/radio_input_spec.rb +234 -0
  109. data/spec/inputs/range_input_spec.rb +477 -0
  110. data/spec/inputs/search_input_spec.rb +55 -0
  111. data/spec/inputs/select_input_spec.rb +545 -0
  112. data/spec/inputs/string_input_spec.rb +163 -0
  113. data/spec/inputs/text_input_spec.rb +158 -0
  114. data/spec/inputs/time_input_spec.rb +155 -0
  115. data/spec/inputs/time_zone_input_spec.rb +87 -0
  116. data/spec/inputs/url_input_spec.rb +55 -0
  117. data/spec/spec.opts +2 -0
  118. data/spec/spec_helper.rb +361 -0
  119. data/spec/support/custom_macros.rb +656 -0
  120. data/spec/support/deferred_garbage_collection.rb +21 -0
  121. data/spec/support/deprecation.rb +6 -0
  122. data/spec/support/test_environment.rb +30 -0
  123. metadata +306 -88
  124. data/generators/form/USAGE +0 -16
  125. data/generators/form/form_generator.rb +0 -111
  126. data/generators/formtastic/formtastic_generator.rb +0 -26
  127. data/init.rb +0 -5
  128. data/lib/formtastic/layout_helper.rb +0 -12
  129. data/lib/generators/formtastic/form/form_generator.rb +0 -84
  130. data/lib/generators/templates/formtastic.css +0 -145
  131. data/lib/generators/templates/formtastic_changes.css +0 -14
  132. data/lib/generators/templates/rails2/_form.html.erb +0 -5
  133. data/lib/generators/templates/rails2/_form.html.haml +0 -4
  134. data/rails/init.rb +0 -2
@@ -0,0 +1,31 @@
1
+ module Formtastic
2
+ module Inputs
3
+ module Base
4
+ module Hints
5
+
6
+ def hint_html
7
+ if hint?
8
+ template.content_tag(
9
+ :p,
10
+ Formtastic::Util.html_safe(hint_text),
11
+ :class => (options[:hint_class] || builder.default_hint_class)
12
+ )
13
+ end
14
+ end
15
+
16
+ def hint?
17
+ !hint_text.blank? && !hint_text.kind_of?(Hash)
18
+ end
19
+
20
+ def hint_text
21
+ localized_string(method, options[:hint], :hint)
22
+ end
23
+
24
+ def hint_text_from_options
25
+ options[:hint]
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,52 @@
1
+ module Formtastic
2
+ module Inputs
3
+ module Base
4
+ module Html
5
+
6
+ # Defines how the instance of an input should be rendered to a HTML string.
7
+ #
8
+ # @abstract Implement this method in your input class to describe how the input should render itself.
9
+ #
10
+ # @example A basic label and text field input inside a standard wrapping might look like this:
11
+ # def to_html
12
+ # input_wrapping do
13
+ # label_html <<
14
+ # builder.text_field(method, input_html_options)
15
+ # end
16
+ # end
17
+ def to_html
18
+ raise NotImplementedError
19
+ end
20
+
21
+ def input_html_options
22
+ {
23
+ :id => dom_id,
24
+ :required => required?,
25
+ :autofocus => autofocus?
26
+ }.merge(options[:input_html] || {})
27
+ end
28
+
29
+ def dom_id
30
+ [
31
+ builder.custom_namespace,
32
+ sanitized_object_name,
33
+ dom_index,
34
+ association_primary_key || sanitized_method_name
35
+ ].reject { |x| x.blank? }.join('_')
36
+ end
37
+
38
+ def dom_index
39
+ if builder.options.has_key?(:index)
40
+ builder.options[:index]
41
+ elsif !builder.auto_index.blank?
42
+ # TODO there's no coverage for this case, not sure how to create a scenario for it
43
+ builder.auto_index
44
+ else
45
+ ""
46
+ end
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,55 @@
1
+ module Formtastic
2
+ module Inputs
3
+ module Base
4
+ module Labelling
5
+
6
+ include Formtastic::LocalizedString
7
+
8
+ def label_html
9
+ render_label? ? builder.label(input_name, label_text, label_html_options) : "".html_safe
10
+ end
11
+
12
+ def label_html_options
13
+ # opts = options_for_label(options) # TODO
14
+ opts = {}
15
+ opts[:for] ||= input_html_options[:id]
16
+ opts[:class] = [opts[:class]]
17
+ opts[:class] << 'label'
18
+
19
+ opts
20
+ end
21
+
22
+ def label_text
23
+ ((localized_label || humanized_method_name) << requirement_text).html_safe
24
+ end
25
+
26
+ # TODO: why does this need to be memoized in order to make the inputs_spec tests pass?
27
+ def requirement_text_or_proc
28
+ @requirement_text_or_proc ||= required? ? builder.required_string : builder.optional_string
29
+ end
30
+
31
+ def requirement_text
32
+ if requirement_text_or_proc.respond_to?(:call)
33
+ requirement_text_or_proc.call
34
+ else
35
+ requirement_text_or_proc
36
+ end
37
+ end
38
+
39
+ def label_from_options
40
+ options[:label]
41
+ end
42
+
43
+ def localized_label
44
+ localized_string(method, label_from_options || method, :label)
45
+ end
46
+
47
+ def render_label?
48
+ return false if options[:label] == false
49
+ true
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,42 @@
1
+ module Formtastic
2
+ module Inputs
3
+ module Base
4
+ module Naming
5
+
6
+ def as
7
+ self.class.name.split("::").last.underscore.gsub(/_input$/, '')
8
+ end
9
+
10
+ def sanitized_object_name
11
+ object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
12
+ end
13
+
14
+ def sanitized_method_name
15
+ @sanitized_method_name ||= method.to_s.gsub(/[\?\/\-]$/, '')
16
+ end
17
+
18
+ def attributized_method_name
19
+ method.to_s.gsub(/_id$/, '').to_sym
20
+ end
21
+
22
+ def humanized_method_name
23
+ if builder.label_str_method != :humanize
24
+ # Special case where label_str_method should trump the human_attribute_name
25
+ # TODO: is this actually a desired bheavior, or should we ditch label_str_method and
26
+ # rely purely on :human_attribute_name.
27
+ method.to_s.send(builder.label_str_method)
28
+ elsif object && object.class.respond_to?(:human_attribute_name)
29
+ object.class.human_attribute_name(method.to_s)
30
+ else
31
+ method.to_s.send(builder.label_str_method)
32
+ end
33
+ end
34
+
35
+ def input_name
36
+ association_primary_key
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,18 @@
1
+ module Formtastic
2
+ module Inputs
3
+ module Base
4
+ module Options
5
+
6
+ def input_options
7
+ options.except(*formtastic_options)
8
+ end
9
+
10
+ def formtastic_options
11
+ [:priority_countries, :priority_zones, :value_method, :label_method, :member_label, :member_value, :collection, :required, :label, :as, :hint, :input_html, :label_html, :value_as_class, :find_options, :class]
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,35 @@
1
+ module Formtastic
2
+ module Inputs
3
+ module Base
4
+ module Stringish
5
+
6
+ # @abstract Override this method in your input class to describe how the input should render itself.
7
+ def to_html
8
+ input_wrapping do
9
+ label_html <<
10
+ builder.text_field(method, input_html_options)
11
+ end
12
+ end
13
+
14
+ # Overrides standard `input_html_options` to provide a `maxlength` and `size` attribute.
15
+ def input_html_options
16
+ {
17
+ :maxlength => options[:input_html].try(:[], :maxlength) || limit,
18
+ :size => builder.default_text_field_size,
19
+ :placeholder => placeholder_text
20
+ }.merge(super)
21
+ end
22
+
23
+ def placeholder_text
24
+ localized_string(method, options[:placeholder], :placeholder)
25
+ end
26
+
27
+ def wrapper_html_options
28
+ new_class = [super[:class], "stringish"].compact.join(" ")
29
+ super.merge(:class => new_class)
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,128 @@
1
+ module Formtastic
2
+ module Inputs
3
+ module Base
4
+ module Timeish
5
+
6
+ def to_html
7
+ input_wrapping do
8
+ fragments_wrapping do
9
+ fragments_label <<
10
+ template.content_tag(:ol,
11
+ fragments.map do |fragment|
12
+ fragment_wrapping do
13
+ fragment_label_html(fragment) <<
14
+ fragment_input_html(fragment)
15
+ end
16
+ end.join.html_safe, # TODO is this safe?
17
+ { :class => 'fragments-group' } # TODO refactor to fragments_group_wrapping
18
+ )
19
+ end
20
+ end
21
+ end
22
+
23
+ def fragments
24
+ date_fragments + time_fragments
25
+ end
26
+
27
+ def time_fragments
28
+ options[:include_seconds] ? [:hour, :minute, :second] : [:hour, :minute]
29
+ end
30
+
31
+ def date_fragments
32
+ options[:order] || i18n_date_fragments || default_date_fragments
33
+ end
34
+
35
+ def default_date_fragments
36
+ [:year, :month, :day]
37
+ end
38
+
39
+ def fragment_wrapping(&block)
40
+ template.content_tag(:li, template.capture(&block), fragment_wrapping_html_options)
41
+ end
42
+
43
+ def fragment_wrapping_html_options
44
+ { :class => 'fragment' }
45
+ end
46
+
47
+ def fragment_label(fragment)
48
+ labels_from_options = options[:labels] || {}
49
+ if labels_from_options.key?(fragment)
50
+ labels_from_options[fragment]
51
+ else
52
+ ::I18n.t(fragment.to_s, :default => fragment.to_s.humanize, :scope => [:datetime, :prompts])
53
+ end
54
+ end
55
+
56
+ def fragment_id(fragment)
57
+ "#{input_html_options[:id]}_#{position(fragment)}i"
58
+ end
59
+
60
+ def fragment_name(fragment)
61
+ "#{method}(#{position(fragment)}i)"
62
+ end
63
+
64
+ def fragment_label_html(fragment)
65
+ text = fragment_label(fragment)
66
+ text.blank? ? "" : template.content_tag(:label, text, :for => fragment_id(fragment))
67
+ end
68
+
69
+ def value
70
+ object.send(method) if object && object.respond_to?(method)
71
+ end
72
+
73
+ def fragment_input_html(fragment)
74
+ opts = input_options.merge(:prefix => object_name, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
75
+ template.send(:"select_#{fragment}", value, opts, input_html_options.merge(:id => fragment_id(fragment)))
76
+ end
77
+
78
+ # TODO extract to BlankOptions or similar -- Select uses similar code
79
+ def include_blank?
80
+ options.key?(:include_blank) ? options[:include_blank] : builder.include_blank_for_select_by_default
81
+ end
82
+
83
+ def positions
84
+ { :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6 }
85
+ end
86
+
87
+ def position(fragment)
88
+ positions[fragment]
89
+ end
90
+
91
+ def i18n_date_fragments
92
+ order = ::I18n.t(:order, :scope => [:date])
93
+ order = nil unless order.is_a?(Array)
94
+ order
95
+ end
96
+
97
+ def fragments_wrapping(&block)
98
+ template.content_tag(:fieldset,
99
+ template.capture(&block).html_safe,
100
+ fragments_wrapping_html_options
101
+ )
102
+ end
103
+
104
+ def fragments_wrapping_html_options
105
+ { :class => "fragments" }
106
+ end
107
+
108
+ def fragments_label
109
+ if render_label?
110
+ template.content_tag(:legend,
111
+ builder.label(method, label_text, :for => "#{input_html_options[:id]}_1i"),
112
+ :class => "label"
113
+ )
114
+ else
115
+ ""
116
+ end
117
+ end
118
+
119
+ def fragments_inner_wrapping(&block)
120
+ template.content_tag(:ol,
121
+ template.capture(&block)
122
+ )
123
+ end
124
+
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,166 @@
1
+ module Formtastic
2
+ module Inputs
3
+ module Base
4
+ module Validations
5
+
6
+ class IndeterminableMinimumAttributeError < ArgumentError
7
+ def message
8
+ [
9
+ "A minimum value can not be determined when the validation uses :greater_than on a :decimal or :float column type.",
10
+ "Please alter the validation to use :greater_than_or_equal_to, or provide a value for this attribute explicitly with the :min option on input()."
11
+ ].join("\n")
12
+ end
13
+ end
14
+
15
+ class IndeterminableMaximumAttributeError < ArgumentError
16
+ def message
17
+ [
18
+ "A maximum value can not be determined when the validation uses :less_than on a :decimal or :float column type.",
19
+ "Please alter the validation to use :less_than_or_equal_to, or provide a value for this attribute explicitly with the :max option on input()."
20
+ ].join("\n")
21
+ end
22
+ end
23
+
24
+ def validations
25
+ @validations ||= if object && object.class.respond_to?(:validators_on)
26
+ object.class.validators_on(attributized_method_name).select do |validator|
27
+ validator_relevant?(validator)
28
+ end
29
+ else
30
+ []
31
+ end
32
+ end
33
+
34
+ def validator_relevant?(validator)
35
+ return true unless validator.options.key?(:if) || validator.options.key?(:unless)
36
+ conditional = validator.options.key?(:if) ? validator.options[:if] : validator.options[:unless]
37
+
38
+ result = if conditional.respond_to?(:call)
39
+ conditional.call(object)
40
+ elsif conditional.is_a?(::Symbol) && object.respond_to?(conditional)
41
+ object.send(conditional)
42
+ else
43
+ conditional
44
+ end
45
+
46
+ result = validator.options.key?(:unless) ? !result : !!result
47
+ not_required_through_negated_validation! if !result && [:presence, :inclusion, :length].include?(validator.kind)
48
+
49
+ result
50
+ end
51
+
52
+ def validation_limit
53
+ validation = validations? && validations.find do |validation|
54
+ validation.kind == :length
55
+ end
56
+ if validation
57
+ validation.options[:maximum] || (validation.options[:within].present? ? validation.options[:within].max : nil)
58
+ else
59
+ nil
60
+ end
61
+ end
62
+
63
+ # Prefer :greater_than_or_equal_to over :greater_than, for no particular reason.
64
+ def validation_min
65
+ validation = validations? && validations.find do |validation|
66
+ validation.kind == :numericality
67
+ end
68
+
69
+ if validation
70
+ # We can't determine an appropriate value for :greater_than with a float/decimal column
71
+ raise IndeterminableMinimumAttributeError if validation.options[:greater_than] && column? && [:float, :decimal].include?(column.type)
72
+
73
+ return validation.options[:greater_than_or_equal_to] if validation.options[:greater_than_or_equal_to]
74
+ return (validation.options[:greater_than] + 1) if validation.options[:greater_than]
75
+ end
76
+ end
77
+
78
+ # Prefer :less_than_or_equal_to over :less_than, for no particular reason.
79
+ def validation_max
80
+ validation = validations? && validations.find do |validation|
81
+ validation.kind == :numericality
82
+ end
83
+ if validation
84
+ # We can't determine an appropriate value for :greater_than with a float/decimal column
85
+ raise IndeterminableMaximumAttributeError if validation.options[:less_than] && column? && [:float, :decimal].include?(column.type)
86
+
87
+ return validation.options[:less_than_or_equal_to] if validation.options[:less_than_or_equal_to]
88
+ return (validation.options[:less_than] - 1) if validation.options[:less_than]
89
+ end
90
+ end
91
+
92
+ def validation_step
93
+ validation = validations? && validations.find do |validation|
94
+ validation.kind == :numericality
95
+ end
96
+ if validation
97
+ validation.options[:step]
98
+ else
99
+ nil
100
+ end
101
+ end
102
+
103
+ def validation_integer_only?
104
+ validation = validations? && validations.find do |validation|
105
+ validation.kind == :numericality
106
+ end
107
+ if validation
108
+ validation.options[:only_integer]
109
+ else
110
+ false
111
+ end
112
+ end
113
+
114
+ def validations?
115
+ !validations.empty?
116
+ end
117
+
118
+ def required?
119
+ return false if options[:required] == false
120
+ return true if options[:required] == true
121
+ return false if not_required_through_negated_validation?
122
+ if validations?
123
+ validations.select { |validator|
124
+ [:presence, :inclusion, :length].include?(validator.kind) &&
125
+ validator.options[:allow_blank] != true
126
+ }.any?
127
+ else
128
+ return responds_to_global_required? && !!builder.all_fields_required_by_default
129
+ end
130
+ end
131
+
132
+ def not_required_through_negated_validation?
133
+ @not_required_through_negated_validation
134
+ end
135
+
136
+ def not_required_through_negated_validation!
137
+ @not_required_through_negated_validation = true
138
+ end
139
+
140
+ def responds_to_global_required?
141
+ true
142
+ end
143
+
144
+ def optional?
145
+ !required?
146
+ end
147
+
148
+ def autofocus?
149
+ opt_autofocus = options[:input_html] && options[:input_html][:autofocus]
150
+
151
+ !!opt_autofocus
152
+ end
153
+
154
+ def column_limit
155
+ column.limit if column? && column.respond_to?(:limit)
156
+ end
157
+
158
+ def limit
159
+ validation_limit || column_limit
160
+ end
161
+
162
+ end
163
+ end
164
+ end
165
+ end
166
+