1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

apply form_for namespace option to date_select

This commit is contained in:
Sergey Nartimov 2012-03-26 21:46:30 +03:00
parent 65f4d8019f
commit 65434a2f25
2 changed files with 12 additions and 1 deletions

View file

@ -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

View file

@ -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)