Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removed the inline_order configuration, override input_wrapping instead

  • Loading branch information...
commit 1d8d5a655a50be266fc70751ffd6d15a2c2923f8 1 parent 1397e87
@justinfrench authored
View
1  CHANGELOG
@@ -1,5 +1,6 @@
[v2 branch]
+* Removed the "inline_order" configuration (redefine input_wrapping instead)
* Removed the "special" implementation of label() from FormBuilder, so builder.label will call Rails' label helper, not ours
* Changed formtastic:form generator include the wrapping semantic_form_for block
* Changed formtastic:form generator to generate a partial by default (instead of copying to clipboard, which can be done with --copy)
View
1  lib/formtastic/form_builder.rb
@@ -47,7 +47,6 @@ def self.configure(name, value = nil)
configure :label_str_method, :humanize
configure :collection_label_methods, %w[to_label display_name full_name name title username login value to_s]
configure :collection_value_methods, %w[id to_s]
- configure :inline_order, [ :input, :hints, :errors ]
configure :custom_inline_order, {}
configure :file_methods, [ :file?, :public_filename, :filename ]
configure :file_metadata_suffixes, ['content_type', 'file_name', 'file_size']
View
3  lib/formtastic/inputs/new_base/html.rb
@@ -29,7 +29,8 @@ def label_html_options
opts
end
- # TODO doesn't cover custom ordering
+ # Override this method if you want to change the display order (for example, rendering the
+ # errors before the body of the input).
def input_wrapping(&block)
template.content_tag(:li,
[template.capture(&block), error_html, hint_html].join("\n").html_safe,
View
6 lib/generators/templates/formtastic.rb
@@ -58,12 +58,6 @@
# Formtastic::FormBuilder.collection_label_methods = [
# "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
-# Formtastic by default renders inside li tags the input, hints and then
-# errors messages. Sometimes you want the hints to be rendered first than
-# the input, in the following order: hints, input and errors. You can
-# customize it doing just as below:
-# Formtastic::FormBuilder.inline_order = [:input, :hints, :errors]
-
# Additionally, you can customize the order for specific types of inputs.
# This is configured on a type basis and if a type is not found it will
# fall back to the default order as defined by #inline_order
View
44 spec/input_spec.rb
@@ -8,47 +8,9 @@
before do
@output_buffer = ''
mock_everything
- end
-
- describe 'with inline order customization' do
- it 'should allow input, hints, errors as order' do
- Formtastic::FormBuilder.inline_order = [:input, :hints, :errors]
-
- semantic_form_for(@new_post) do |builder|
- builder.should_receive(:inline_input_for).once.ordered
- builder.should_receive(:inline_hints_for).once.ordered
- builder.should_receive(:inline_errors_for).once.ordered
- concat(builder.input(:title))
- end
- end
-
- it 'should allow hints, input, errors as order' do
- Formtastic::FormBuilder.inline_order = [:hints, :input, :errors]
-
- semantic_form_for(@new_post) do |builder|
- builder.should_receive(:inline_hints_for).once.ordered
- builder.should_receive(:inline_input_for).once.ordered
- builder.should_receive(:inline_errors_for).once.ordered
- concat(builder.input(:title))
- end
- end
-
- it 'should allow errors, input, hint for a custom type while preserving original inline order' do
- Formtastic::FormBuilder.custom_inline_order[:checkbox] = [:errors, :input, :hints]
- Formtastic::FormBuilder.inline_order = [:hints, :input, :errors]
-
- semantic_form_for(@new_post) do |builder|
- builder.should_receive(:inline_errors_for).once.ordered
- builder.should_receive(:inline_input_for).once.ordered
- builder.should_receive(:inline_hints_for).once.ordered
- concat(builder.input(:title, :as => :checkbox))
- builder.should_receive(:inline_hints_for).once.ordered
- builder.should_receive(:inline_input_for).once.ordered
- builder.should_receive(:inline_errors_for).once.ordered
- concat(builder.input(:title))
- end
- end
-
+
+ @errors = mock('errors')
+ @new_post.stub!(:errors).and_return(@errors)
end
describe 'arguments and options' do

0 comments on commit 1d8d5a6

Please sign in to comment.
Something went wrong with that request. Please try again.