aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-03-26 13:10:05 -0700
committerPiotr Sarnacki <drogus@gmail.com>2012-03-26 13:10:05 -0700
commitea0789f08d69beb9ddb2ca64c69c4da8f5bd0222 (patch)
tree1bd9c820967de24cad468fba407356de4533a399
parent9637de6b472b05a09fe6d28d973b4729e3ea4615 (diff)
parent65434a2f259e94ebacccd1166e5d6a93d0b77732 (diff)
downloadrails-ea0789f08d69beb9ddb2ca64c69c4da8f5bd0222.tar.gz
rails-ea0789f08d69beb9ddb2ca64c69c4da8f5bd0222.tar.bz2
rails-ea0789f08d69beb9ddb2ca64c69c4da8f5bd0222.zip
Merge pull request #5594 from lest/patch-1
apply form_for namespace option to date_select
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb5
-rw-r--r--actionpack/test/template/form_helper_test.rb8
2 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 2bfc6371f5..45e5a862b6 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -977,7 +977,10 @@ module ActionView
# Returns the id attribute for the input tag.
# => "post_written_on_1i"
def input_id_from_type(type)
- input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '')
+ id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '')
+ id = @options[:namespace] + '_' + id if @options[:namespace]
+
+ id
end
# Given an ordering of datetime components, create the selection HTML
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 2bdb54bd5e..c5de736ffb 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1063,6 +1063,14 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_form_for_with_namespace_with_date_select
+ form_for(@post, :namespace => 'namespace') do |f|
+ concat f.date_select(:written_on)
+ end
+
+ assert_select 'select#namespace_post_written_on_1i'
+ end
+
def test_form_for_with_namespace_with_label
form_for(@post, :namespace => 'namespace') do |f|
concat f.label(:title)