Skip to content
Browse files

Revert "Merge pull request #773 from mhuggins/indexed-labels"

This reverts commit 5641f43, reversing
changes made to 1df5245.
  • Loading branch information...
1 parent 93e1757 commit 00398355b2353b5e05ff49edc265314aeaa994f6 @justinfrench committed Jan 14, 2012
Showing with 3 additions and 55 deletions.
  1. +1 −17 lib/formtastic/inputs/base/labelling.rb
  2. +2 −38 spec/helpers/inputs_helper_spec.rb
View
18 lib/formtastic/inputs/base/labelling.rb
@@ -20,9 +20,7 @@ def label_html_options
end
def label_text
- text = ((localized_label || humanized_method_name) << requirement_text)
- text %= input_index
- text.html_safe
+ ((localized_label || humanized_method_name) << requirement_text).html_safe
end
# TODO: why does this need to be memoized in order to make the inputs_spec tests pass?
@@ -51,20 +49,6 @@ def render_label?
true
end
- def input_index
- # Try to get parent builder's @nested_child_index Hash, which contains the current
- # index of the form element we want to look up. Fall back on empty Hash otherwise.
- parent = builder.parent_builder
- duck = parent ? parent.instance_variable_get('@nested_child_index') : {}
-
- # Strip the index from the @nested_child_index, e.g.:
- # `post[comment_attributes][0]` becomes `post[comment_attributes]`
- key = builder.object_name
- key = key.gsub(/\[[0-9]+\]$/, '') if key.is_a?(String)
-
- duck[key].to_i + 1
- end
-
end
end
end
View
40 spec/helpers/inputs_helper_spec.rb
@@ -122,18 +122,6 @@
output_buffer.should have_tag("form input[@name='post[authors_attributes][1][login]']")
output_buffer.should_not have_tag('form fieldset[@name]')
end
-
- it 'should include an indexed :label input for each item' do
- concat(semantic_form_for(@new_post) do |post|
- post.inputs :for => :authors do |author|
- concat(author.input(:login, :label => '%i', :required => false))
- end
- end)
-
- output_buffer.should have_tag("form fieldset.inputs label", "1", :count => 1)
- output_buffer.should have_tag("form fieldset.inputs label", "2", :count => 1)
- output_buffer.should_not have_tag('form fieldset legend')
- end
end
describe 'as an array containing the a symbole for the association name and the associated object' do
@@ -199,7 +187,7 @@
output_buffer.should_not have_tag('fieldset[@builder="Formtastic::Helpers::FormHelper"]')
end
- it 'should send parent_builder as an option to allow child index interpolation for legends' do
+ it 'should send parent_builder as an option to allow child index interpolation' do
concat(semantic_form_for(@new_post) do |builder|
builder.instance_variable_set('@nested_child_index', 0)
inputs = builder.inputs :for => [:author, @bob], :name => 'Author #%i' do |bob_builder|
@@ -211,7 +199,7 @@
output_buffer.should have_tag('fieldset legend', 'Author #1')
end
- it 'should also provide child index interpolation for legends when nested child index is a hash' do
+ it 'should also provide child index interpolation when nested child index is a hash' do
concat(semantic_form_for(@new_post) do |builder|
builder.instance_variable_set('@nested_child_index', :author => 10)
inputs = builder.inputs :for => [:author, @bob], :name => 'Author #%i' do |bob_builder|
@@ -222,30 +210,6 @@
output_buffer.should have_tag('fieldset legend', 'Author #11')
end
-
- it 'should send parent_builder as an option to allow child index interpolation for labels' do
- concat(semantic_form_for(@new_post) do |builder|
- builder.instance_variable_set('@nested_child_index', 'post[author_attributes]' => 0)
- inputs = builder.inputs :for => [:author, @bob] do |bob_builder|
- concat(bob_builder.input(:name, :label => 'Author #%i', :required => false))
- end
- concat(inputs)
- end)
-
- output_buffer.should have_tag('fieldset label', 'Author #1')
- end
-
- it 'should also provide child index interpolation for labels when nested child index is a hash' do
- concat(semantic_form_for(@new_post) do |builder|
- builder.instance_variable_set('@nested_child_index', 'post[author_attributes]' => 10)
- inputs = builder.inputs :for => [:author, @bob] do |bob_builder|
- concat(bob_builder.input(:name, :label => 'Author #%i', :required => false))
- end
- concat(inputs)
- end)
-
- output_buffer.should have_tag('fieldset label', 'Author #11')
- end
end
describe 'when a :name or :title option is provided' do

0 comments on commit 0039835

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