Skip to content
This repository
Browse code

Merge pull request #5596 from lest/patch-3

apply form_for namespace option to date_select
  • Loading branch information...
commit 3f1b8c6a95fcdcdc14ecd0f6fe1758a1e1044269 2 parents ed7567c + bd8a970
Piotr Sarnacki authored March 26, 2012
5  actionpack/lib/action_view/helpers/date_helper.rb
@@ -940,7 +940,10 @@ def input_name_from_type(type)
940 940
         # Returns the id attribute for the input tag.
941 941
         #  => "post_written_on_1i"
942 942
         def input_id_from_type(type)
943  
-          input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '')
  943
+          id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '')
  944
+          id = @options[:namespace] + '_' + id if @options[:namespace]
  945
+
  946
+          id
944 947
         end
945 948
 
946 949
         # Given an ordering of datetime components, create the selection HTML
8  actionpack/test/template/form_helper_test.rb
@@ -960,6 +960,14 @@ def test_form_for_with_namespace
960 960
     assert_dom_equal expected, output_buffer
961 961
   end
962 962
 
  963
+  def test_form_for_with_namespace_with_date_select
  964
+    form_for(@post, :namespace => 'namespace') do |f|
  965
+      concat f.date_select(:written_on)
  966
+    end
  967
+
  968
+    assert_select 'select#namespace_post_written_on_1i'
  969
+  end
  970
+
963 971
   def test_form_for_with_namespace_with_label
964 972
     form_for(@post, :namespace => 'namespace') do |f|
965 973
       concat f.label(:title)

0 notes on commit 3f1b8c6

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