Skip to content

Commit

Permalink
Merge pull request #5594 from lest/patch-1
Browse files Browse the repository at this point in the history
apply form_for namespace option to date_select
  • Loading branch information
drogus committed Mar 26, 2012
2 parents 9637de6 + 65434a2 commit ea0789f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion actionpack/lib/action_view/helpers/date_helper.rb
Expand Up @@ -977,7 +977,10 @@ def input_name_from_type(type)
# Returns the id attribute for the input tag. # Returns the id attribute for the input tag.
# => "post_written_on_1i" # => "post_written_on_1i"
def input_id_from_type(type) 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 end


# Given an ordering of datetime components, create the selection HTML # Given an ordering of datetime components, create the selection HTML
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/template/form_helper_test.rb
Expand Up @@ -1063,6 +1063,14 @@ def test_form_for_with_namespace
assert_dom_equal expected, output_buffer assert_dom_equal expected, output_buffer
end 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 def test_form_for_with_namespace_with_label
form_for(@post, :namespace => 'namespace') do |f| form_for(@post, :namespace => 'namespace') do |f|
concat f.label(:title) concat f.label(:title)
Expand Down

0 comments on commit ea0789f

Please sign in to comment.