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,14 @@
1
+ module Formtastic
2
+ module Inputs
3
+ # @see Formtastic::Inputs::Timeish Timeish module for documetation of date, time and datetime input options.
4
+ class TimeInput
5
+ include Base
6
+ include Base::Timeish
7
+
8
+ # we don't want year / month / day fragments in a time select
9
+ def date_fragments
10
+ []
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,48 @@
1
+ module Formtastic
2
+ module Inputs
3
+
4
+ # Outputs a `<label>` with a `<select>` containing a series of time zones (using Rails' own
5
+ # `time_zone_select` helper), wrapped in the standard `<li>` wrapper.
6
+
7
+ # This is the default input choice for attributes matching /time_zone/, but can be applied to
8
+ # any text-like input with `:as => :time_zone`.
9
+ #
10
+ # @example Full form context and output
11
+ #
12
+ # <%= semantic_form_for(@user) do |f| %>
13
+ # <%= f.inputs do %>
14
+ # <%= f.input :time_zone, :as => :time_zone %>
15
+ # <% end %>
16
+ # <% end %>
17
+ #
18
+ # <form...>
19
+ # <fieldset>
20
+ # <ol>
21
+ # <li class="time_zone">
22
+ # <label for="user_time_zone">Time zone</label>
23
+ # <input type="text" id="user_time_zone" name="user[time_zone]">
24
+ # </li>
25
+ # </ol>
26
+ # </fieldset>
27
+ # </form>
28
+ #
29
+ # @see Formtastic::Helpers::InputsHelper#input InputsHelper#input for full documetation of all possible options.
30
+ #
31
+ # @todo document :priority_zones option
32
+ # @todo configurable default :priority_zones?
33
+ class TimeZoneInput
34
+ include Base
35
+
36
+ def to_html
37
+ input_wrapping do
38
+ label_html <<
39
+ builder.time_zone_select(method, priority_zones, input_options, input_html_options)
40
+ end
41
+ end
42
+
43
+ def priority_zones
44
+ options[:priority_zones] || [] # TODO config?
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,40 @@
1
+ module Formtastic
2
+ module Inputs
3
+
4
+ # Outputs a simple `<label>` with a HTML5 `<input type="url">` wrapped in the standard
5
+ # `<li>` wrapper. This is the default input choice for all attributes matching
6
+ # `/^url$|^website$|_url$/`, but can be applied to any text-like input with `:as => :url`.
7
+ #
8
+ # @example Full form context and output
9
+ #
10
+ # <%= semantic_form_for(@user) do |f| %>
11
+ # <%= f.inputs do %>
12
+ # <%= f.input :home_page, :as => :url %>
13
+ # <% end %>
14
+ # <% end %>
15
+ #
16
+ # <form...>
17
+ # <fieldset>
18
+ # <ol>
19
+ # <li class="url">
20
+ # <label for="user_home_page">Home page</label>
21
+ # <input type="number" id="user_home_page" name="user[home_page]">
22
+ # </li>
23
+ # </ol>
24
+ # </fieldset>
25
+ # </form>
26
+ #
27
+ # @see Formtastic::Helpers::InputsHelper#input InputsHelper#input for full documetation of all possible options.
28
+ class UrlInput
29
+ include Base
30
+ include Base::Stringish
31
+
32
+ def to_html
33
+ input_wrapping do
34
+ label_html <<
35
+ builder.url_field(method, input_html_options)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,105 @@
1
+ module Formtastic
2
+ # @private
3
+ module LocalizedString
4
+
5
+ protected
6
+
7
+ # Internal generic method for looking up localized values within Formtastic
8
+ # using I18n, if no explicit value is set and I18n-lookups are enabled.
9
+ #
10
+ # Enabled/Disable this by setting:
11
+ #
12
+ # Formtastic::FormBuilder.i18n_lookups_by_default = true/false
13
+ #
14
+ # Lookup priority:
15
+ #
16
+ # 'formtastic.%{type}.%{model}.%{action}.%{attribute}'
17
+ # 'formtastic.%{type}.%{model}.%{attribute}'
18
+ # 'formtastic.%{type}.%{attribute}'
19
+ #
20
+ # Example:
21
+ #
22
+ # 'formtastic.labels.post.edit.title'
23
+ # 'formtastic.labels.post.title'
24
+ # 'formtastic.labels.title'
25
+ #
26
+ # NOTE: Generic, but only used for form input titles/labels/hints/actions (titles = legends, actions = buttons).
27
+ #
28
+ def localized_string(key, value, type, options = {}) #:nodoc:
29
+ key = value if value.is_a?(::Symbol)
30
+
31
+ if value.is_a?(::String)
32
+ escape_html_entities(value)
33
+ else
34
+ use_i18n = value.nil? ? i18n_lookups_by_default : (value != false)
35
+
36
+ if use_i18n
37
+ model_name, nested_model_name = normalize_model_name(self.model_name.underscore)
38
+
39
+ action_name = template.params[:action].to_s rescue ''
40
+ attribute_name = key.to_s
41
+
42
+ defaults = Formtastic::I18n::SCOPES.reject do |i18n_scope|
43
+ nested_model_name.nil? && i18n_scope.match(/nested_model/)
44
+ end.collect do |i18n_scope|
45
+ i18n_path = i18n_scope.dup
46
+ i18n_path.gsub!('%{action}', action_name)
47
+ i18n_path.gsub!('%{model}', model_name)
48
+ i18n_path.gsub!('%{nested_model}', nested_model_name) unless nested_model_name.nil?
49
+ i18n_path.gsub!('%{attribute}', attribute_name)
50
+ i18n_path.gsub!('..', '.')
51
+ i18n_path.to_sym
52
+ end
53
+ defaults << ''
54
+
55
+ defaults.uniq!
56
+
57
+ default_key = defaults.shift
58
+ i18n_value = Formtastic::I18n.t(default_key,
59
+ options.merge(:default => defaults, :scope => type.to_s.pluralize.to_sym))
60
+ i18n_value = i18n_value.is_a?(::String) ? i18n_value : nil
61
+ if i18n_value.blank? && type == :label
62
+ # This is effectively what Rails label helper does for i18n lookup
63
+ options[:scope] = [:helpers, type]
64
+ options[:default] = defaults
65
+ i18n_value = ::I18n.t(default_key, options)
66
+ end
67
+ (i18n_value.is_a?(::String) && i18n_value.present?) ? escape_html_entities(i18n_value) : nil
68
+ end
69
+ end
70
+ end
71
+
72
+ def model_name
73
+ @object.present? ? @object.class.name : @object_name.to_s.classify
74
+ end
75
+
76
+ def normalize_model_name(name)
77
+ if !name =~ /\[/ && self.respond_to?(:builder) && builder.respond_to?(:parent_builder) && builder.parent_builder.object_name
78
+ # Rails 3.1 nested builder case
79
+ [builder.parent_builder.object_name.to_s, name]
80
+ elsif name =~ /(.+)\[(.+)\]/
81
+ # Rails 3 (and 3.1?) nested builder case with :post rather than @post
82
+ [$1, $2]
83
+ elsif self.respond_to?(:builder) && builder.respond_to?(:options) && builder.options.key?(:parent_builder)
84
+ # Rails 3.0 nested builder work-around case, where :parent_builder is provided by f.semantic_form_for
85
+ [builder.options[:parent_builder].object_name.to_s, name]
86
+ else
87
+ # Non-nested case
88
+ [name]
89
+ end
90
+ end
91
+
92
+ def escape_html_entities(string) #:nodoc:
93
+ if (respond_to?(:builder) && builder.escape_html_entities_in_hints_and_labels) ||
94
+ (self.respond_to?(:escape_html_entities_in_hints_and_labels) && escape_html_entities_in_hints_and_labels)
95
+ string = template.escape_once(string) unless string.respond_to?(:html_safe?) && string.html_safe? == true # Acceppt html_safe flag as indicator to skip escaping
96
+ end
97
+ string
98
+ end
99
+
100
+ def i18n_lookups_by_default
101
+ respond_to?(:builder) ? builder.i18n_lookups_by_default : i18n_lookups_by_default
102
+ end
103
+
104
+ end
105
+ end
@@ -1,14 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'formtastic'
4
- require 'formtastic/layout_helper'
5
- require 'rails'
6
-
7
3
  module Formtastic
4
+ # @private
8
5
  class Railtie < Rails::Railtie
9
- initializer 'formtastic.initialize', :after => :after_initialize do
10
- ActionView::Base.send :include, Formtastic::SemanticFormHelper
11
- ActionView::Base.send(:include, Formtastic::LayoutHelper)
6
+ initializer 'formtastic.initialize' do
7
+ ActiveSupport.on_load(:action_view) do
8
+ include Formtastic::Helpers::FormHelper
9
+ end
12
10
  end
13
11
  end
14
12
  end
@@ -0,0 +1,11 @@
1
+ module Formtastic
2
+ # Quick hack/shim so that any code expecting the old SemanticFormBuilder class still works.
3
+ # TODO remove from 2.0 with a helpful upgrade path/warning.
4
+ # @private
5
+ class SemanticFormBuilder < Formtastic::FormBuilder
6
+ def initialize(*args)
7
+ ActiveSupport::Deprecation.warn('Formtastic::SemanticFormBuilder has been deprecated in favor of Formtastic::FormBuilder.', caller)
8
+ super
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # Adapted from the rails3 compatibility shim in Haml 2.2
4
4
  module Formtastic
5
+ # @private
5
6
  module Util
6
7
  extend self
7
8
  ## Rails XSS Safety
@@ -13,26 +14,12 @@ module Formtastic
13
14
  # @param text [String]
14
15
  # @return [String] `text`, marked as HTML-safe
15
16
  def html_safe(text)
16
- return text if text.nil?
17
- return text.html_safe if defined?(ActiveSupport::SafeBuffer)
18
- return text.html_safe! if text.respond_to?(:html_safe!)
19
- text
17
+ if text.respond_to?(:html_safe)
18
+ text.html_safe
19
+ else
20
+ text
21
+ end
20
22
  end
21
23
 
22
- def rails_safe_buffer_class
23
- # It's important that we check ActiveSupport first,
24
- # because in Rails 2.3.6 ActionView::SafeBuffer exists
25
- # but is a deprecated proxy object.
26
- return ActiveSupport::SafeBuffer if defined?(ActiveSupport::SafeBuffer)
27
- return ActionView::SafeBuffer
28
- end
29
-
30
- def rails3?
31
- version=
32
- if defined?(ActionPack::VERSION::MAJOR)
33
- ActionPack::VERSION::MAJOR
34
- end
35
- !version.blank? && version >= 3
36
- end
37
24
  end
38
25
  end
@@ -0,0 +1,3 @@
1
+ module Formtastic
2
+ VERSION = "2.0.0.rc1"
3
+ end
@@ -1,15 +1,37 @@
1
1
  # encoding: utf-8
2
+
2
3
  module Formtastic
4
+ # Copies formtastic.css to public/stylesheets/ (Rails 3.0.x only) and a config initializer
5
+ # to config/initializers/formtastic.rb (all Rails versions).
6
+ #
7
+ # @example
8
+ # $ rails generate formtastic:install
9
+ #
10
+ # @todo Test with Rails 3.0
3
11
  class InstallGenerator < Rails::Generators::Base
4
- desc "Copies formtastic.css and formtastic_changes.css to public/stylesheets/ and a config initializer to config/initializers/formtastic_config.rb"
5
-
6
12
  source_root File.expand_path('../../../templates', __FILE__)
13
+ class_option :template_engine
7
14
 
8
- def copy_files
9
- template 'formtastic.rb', 'config/initializers/formtastic.rb'
15
+ if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1
16
+ # Rails 3.1 has the asset pipeline, no need to copy CSS files any more
17
+ desc "Copies a config initializer to config/initializers/formtastic.rb"
18
+ def copy_files
19
+ copy_file 'formtastic.rb', 'config/initializers/formtastic.rb'
20
+ end
21
+ else
22
+ # Rails 3.0 doesn't have an asset pipeline, so we copy in CSS too
23
+ desc "Copies some CSS files to public/stylesheets/ and a config initializer to config/initializers/formtastic.rb"
24
+ def copy_files
25
+ template 'formtastic.rb', 'config/initializers/formtastic.rb'
26
+ template '../../../app/assets/stylesheets/formtastic.css', 'public/stylesheets/formtastic.css'
27
+ template '../../../app/assets/stylesheets/formtastic_ie6.css', 'public/stylesheets/formtastic_ie6.css'
28
+ template '../../../app/assets/stylesheets/formtastic_ie7.css', 'public/stylesheets/formtastic_ie7.css'
29
+ end
30
+ end
10
31
 
11
- template 'formtastic.css', 'public/stylesheets/formtastic.css'
12
- template 'formtastic_changes.css', 'public/stylesheets/formtastic_changes.css'
32
+ def copy_scaffold_template
33
+ engine = options[:template_engine]
34
+ copy_file "_form.html.#{engine}", "lib/templates/#{engine}/scaffold/_form.html.#{engine}"
13
35
  end
14
36
  end
15
37
  end
@@ -1,5 +1,11 @@
1
- <%%= f.inputs do %>
2
- <% attributes.each do |attribute| -%>
3
- <%%= f.input :<%= attribute.name %> %>
4
- <% end -%>
1
+ <%%= semantic_form_for @<%= singular_name %> do |f| %>
2
+ <%%= f.inputs do %>
3
+ <%- attributes.each do |attribute| -%>
4
+ <%%= f.input :<%= attribute.name %> %>
5
+ <%- end -%>
6
+ <%% end %>
7
+
8
+ <%%= f.buttons do %>
9
+ <%%= f.commit_button %>
10
+ <%% end %>
5
11
  <%% end %>
@@ -1,4 +1,8 @@
1
- = f.inputs do
2
- <% attributes.each do |attribute| -%>
3
- = f.input :<%= attribute.name %>
4
- <% end -%>
1
+ = semantic_form_for @<%= singular_name %> do |f|
2
+ = f.inputs do
3
+ <% attributes.each do |attribute| -%>
4
+ = f.input :<%= attribute.name %>
5
+ <% end -%>
6
+
7
+ = f.buttons do
8
+ = f.commit_button
@@ -1,80 +1,73 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  # --------------------------------------------------------------------------------------------------
4
- # Please note: If you're subclassing Formtastic::SemanticFormBuilder in a Rails 3 project,
5
- # Formtastic uses class_attribute for these configuration attributes instead of the deprecated
6
- # class_inheritable_attribute. The behaviour is slightly different with subclasses (especially
7
- # around attributes with Hash or Array) values, so make sure you understand what's happening.
4
+ # Please note: If you're subclassing Formtastic::FormBuilder, Formtastic uses
5
+ # class_attribute for these configuration attributes instead of the deprecated
6
+ # class_inheritable_attribute. The behaviour is slightly different with subclasses (especially
7
+ # around attributes with Hash or Array) values, so make sure you understand what's happening.
8
8
  # See the documentation for class_attribute in ActiveSupport for more information.
9
9
  # --------------------------------------------------------------------------------------------------
10
10
 
11
11
  # Set the default text field size when input is a string. Default is nil.
12
- # Formtastic::SemanticFormBuilder.default_text_field_size = 50
12
+ # Formtastic::FormBuilder.default_text_field_size = 50
13
13
 
14
14
  # Set the default text area height when input is a text. Default is 20.
15
- # Formtastic::SemanticFormBuilder.default_text_area_height = 5
15
+ # Formtastic::FormBuilder.default_text_area_height = 5
16
16
 
17
17
  # Set the default text area width when input is a text. Default is nil.
18
- # Formtastic::SemanticFormBuilder.default_text_area_width = 50
18
+ # Formtastic::FormBuilder.default_text_area_width = 50
19
19
 
20
20
  # Should all fields be considered "required" by default?
21
- # Rails 2 only, ignored by Rails 3 because it will never fall back to this default.
22
21
  # Defaults to true.
23
- # Formtastic::SemanticFormBuilder.all_fields_required_by_default = true
22
+ # Formtastic::FormBuilder.all_fields_required_by_default = true
24
23
 
25
24
  # Should select fields have a blank option/prompt by default?
26
25
  # Defaults to true.
27
- # Formtastic::SemanticFormBuilder.include_blank_for_select_by_default = true
26
+ # Formtastic::FormBuilder.include_blank_for_select_by_default = true
28
27
 
29
28
  # Set the string that will be appended to the labels/fieldsets which are required
30
29
  # It accepts string or procs and the default is a localized version of
31
30
  # '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
32
31
  # in your locale, it will replace the abbr title properly. But if you don't want to use
33
32
  # abbr tag, you can simply give a string as below
34
- # Formtastic::SemanticFormBuilder.required_string = "(required)"
33
+ # Formtastic::FormBuilder.required_string = "(required)"
35
34
 
36
35
  # Set the string that will be appended to the labels/fieldsets which are optional
37
36
  # Defaults to an empty string ("") and also accepts procs (see required_string above)
38
- # Formtastic::SemanticFormBuilder.optional_string = "(optional)"
37
+ # Formtastic::FormBuilder.optional_string = "(optional)"
39
38
 
40
39
  # Set the way inline errors will be displayed.
41
40
  # Defaults to :sentence, valid options are :sentence, :list, :first and :none
42
- # Formtastic::SemanticFormBuilder.inline_errors = :sentence
41
+ # Formtastic::FormBuilder.inline_errors = :sentence
43
42
  # Formtastic uses the following classes as default for hints, inline_errors and error list
44
43
 
45
- # If you override the class here, please ensure to override it in your formtastic_changes.css stylesheet as well
46
- # Formtastic::SemanticFormBuilder.default_hint_class = "inline-hints"
47
- # Formtastic::SemanticFormBuilder.default_inline_error_class = "inline-errors"
48
- # Formtastic::SemanticFormBuilder.default_error_list_class = "errors"
44
+ # If you override the class here, please ensure to override it in your stylesheets as well
45
+ # Formtastic::FormBuilder.default_hint_class = "inline-hints"
46
+ # Formtastic::FormBuilder.default_inline_error_class = "inline-errors"
47
+ # Formtastic::FormBuilder.default_error_list_class = "errors"
49
48
 
50
49
  # Set the method to call on label text to transform or format it for human-friendly
51
50
  # reading when formtastic is used without object. Defaults to :humanize.
52
- # Formtastic::SemanticFormBuilder.label_str_method = :humanize
51
+ # Formtastic::FormBuilder.label_str_method = :humanize
53
52
 
54
53
  # Set the array of methods to try calling on parent objects in :select and :radio inputs
55
54
  # for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
56
55
  # that is found on the object will be used.
57
56
  # Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
58
- # Formtastic::SemanticFormBuilder.collection_label_methods = [
57
+ # Formtastic::FormBuilder.collection_label_methods = [
59
58
  # "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
60
59
 
61
- # Formtastic by default renders inside li tags the input, hints and then
62
- # errors messages. Sometimes you want the hints to be rendered first than
63
- # the input, in the following order: hints, input and errors. You can
64
- # customize it doing just as below:
65
- # Formtastic::SemanticFormBuilder.inline_order = [:input, :hints, :errors]
66
-
67
60
  # Additionally, you can customize the order for specific types of inputs.
68
61
  # This is configured on a type basis and if a type is not found it will
69
62
  # fall back to the default order as defined by #inline_order
70
- # Formtastic::SemanticFormBuilder.custom_inline_order[:checkbox] = [:errors, :hints, :input]
71
- # Formtastic::SemanticFormBuilder.custom_inline_order[:select] = [:hints, :input, :errors]
63
+ # Formtastic::FormBuilder.custom_inline_order[:checkbox] = [:errors, :hints, :input]
64
+ # Formtastic::FormBuilder.custom_inline_order[:select] = [:hints, :input, :errors]
72
65
 
73
66
  # Specifies if labels/hints for input fields automatically be looked up using I18n.
74
- # Default value: false. Overridden for specific fields by setting value to true,
67
+ # Default value: true. Overridden for specific fields by setting value to true,
75
68
  # i.e. :label => true, or :hint => true (or opposite depending on initialized value)
76
- # Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
69
+ # Formtastic::FormBuilder_lookups_by_default = false
77
70
 
78
- # You can add custom inputs or override parts of Formtastic by subclassing SemanticFormBuilder and
79
- # specifying that class here. Defaults to SemanticFormBuilder.
80
- # Formtastic::SemanticFormHelper.builder = MyCustomBuilder
71
+ # You can add custom inputs or override parts of Formtastic by subclassing Formtastic::FormBuilder and
72
+ # specifying that class here. Defaults to Formtastic::FormBuilder.
73
+ # Formtastic::Helpers::FormHelper.builder = MyCustomBuilder