diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-09-06 05:53:29 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-09-06 05:53:29 +0000 |
commit | 0e6c8e5f6c168b9d376122f730c604d3758f4b04 (patch) | |
tree | fdb197bdbd56852d20203b0f9d64053dc9b4582d /actionpack/lib | |
parent | 8a9f43ecbb99f470cc8720c09a1c9480abdc845e (diff) | |
download | rails-0e6c8e5f6c168b9d376122f730c604d3758f4b04.tar.gz rails-0e6c8e5f6c168b9d376122f730c604d3758f4b04.tar.bz2 rails-0e6c8e5f6c168b9d376122f730c604d3758f4b04.zip |
Add fieldset_tag for generating fieldsets, closes #9477. [djanowski]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7413 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index c3cabb10f7..39e508f433 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -363,6 +363,28 @@ module ActionView def image_submit_tag(source, options = {}) tag :input, { "type" => "image", "src" => image_path(source) }.update(options.stringify_keys) end + + # Creates a field set for grouping HTML form elements. + # + # <tt>legend</tt> will become the fieldset's title (optional as per W3C). + # + # === Examples + # <% fieldset_tag do %> + # <p><%= text_field_tag 'name' %></p> + # <% end %> + # # => <fieldset><p><input id="name" name="name" type="text" /></p></fieldset> + # + # <% fieldset_tag 'Your details' do %> + # <p><%= text_field_tag 'name' %></p> + # <% end %> + # # => <fieldset><legend>Your details</legend><p><input id="name" name="name" type="text" /></p></fieldset> + def fieldset_tag(legend = nil, &block) + content = capture(&block) + concat(tag(:fieldset, {}, true), block.binding) + concat(content_tag(:legend, legend), block.binding) unless legend.blank? + concat(content, block.binding) + concat("</fieldset>", block.binding) + end private def html_options_for_form(url_for_options, options, *parameters_for_url) |