aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-03-26 12:27:52 +0000
committerPratik Naik <pratiknaik@gmail.com>2008-03-26 12:27:52 +0000
commitca9413674ea70dc67ab517734af2e40dac21beef (patch)
tree86cbf305a2b1b4688a5b6f7cfbce8a9aa505c5f7 /actionpack/lib/action_view/helpers/form_helper.rb
parent5c47ceb30b940a8cd8eb681a898895bce46f79dd (diff)
downloadrails-ca9413674ea70dc67ab517734af2e40dac21beef.tar.gz
rails-ca9413674ea70dc67ab517734af2e40dac21beef.tar.bz2
rails-ca9413674ea70dc67ab517734af2e40dac21beef.zip
Improve documentation.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9093 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 22c6562cc7..0e77a7e067 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -76,6 +76,7 @@ module ActionView
# values for the fields.
#
# <% form_for :person, @person, :url => { :action => "update" } do |f| %>
+ # <%= f.error_messages %>
# First name: <%= f.text_field :first_name %>
# Last name : <%= f.text_field :last_name %>
# Biography : <%= f.text_area :biography %>
@@ -85,7 +86,8 @@ module ActionView
# Worth noting is that the form_for tag is called in a ERb evaluation block, not an ERb output block. So that's <tt><% %></tt>,
# not <tt><%= %></tt>. Also worth noting is that form_for yields a <tt>form_builder</tt> object, in this example as <tt>f</tt>, which emulates
# the API for the stand-alone FormHelper methods, but without the object name. So instead of <tt>text_field :person, :name</tt>,
- # you get away with <tt>f.text_field :name</tt>.
+ # you get away with <tt>f.text_field :name</tt>. Notice that you can even do <tt><%= f.error_messages %></tt> to display the
+ # error messsages of the model object in question.
#
# Even further, the form_for method allows you to more easily escape the instance variable convention. So while the stand-alone
# approach would require <tt>text_field :person, :name, :object => person</tt>
@@ -405,7 +407,7 @@ module ActionView
# ==== Examples
# # Let's say that @post.validated? is 1:
# check_box("post", "validated")
- # # => <input type="checkbox" id="post_validate" name="post[validated]" value="1" checked="checked" />
+ # # => <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
# # <input name="post[validated]" type="hidden" value="0" />
#
# # Let's say that @puppy.gooddog is "no":
@@ -413,8 +415,8 @@ module ActionView
# # => <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
# # <input name="puppy[gooddog]" type="hidden" value="no" />
#
- # check_box("eula", "accepted", {}, "yes", "no", :class => 'eula_check')
- # # => <input type="checkbox" id="eula_accepted" name="eula[accepted]" value="no" />
+ # check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no")
+ # # => <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
# # <input name="eula[accepted]" type="hidden" value="no" />
#
def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
@@ -430,13 +432,13 @@ module ActionView
# # Let's say that @post.category returns "rails":
# radio_button("post", "category", "rails")
# radio_button("post", "category", "java")
- # # => <input type="radio" id="post_category" name="post[category]" value="rails" checked="checked" />
- # # <input type="radio" id="post_category" name="post[category]" value="java" />
+ # # => <input type="radio" id="post_category_rails" name="post[category]" value="rails" checked="checked" />
+ # # <input type="radio" id="post_category_java" name="post[category]" value="java" />
#
# radio_button("user", "receive_newsletter", "yes")
# radio_button("user", "receive_newsletter", "no")
- # # => <input type="radio" id="user_receive_newsletter" name="user[receive_newsletter]" value="yes" />
- # # <input type="radio" id="user_receive_newsletter" name="user[receive_newsletter]" value="no" checked="checked" />
+ # # => <input type="radio" id="user_receive_newsletter_yes" name="user[receive_newsletter]" value="yes" />
+ # # <input type="radio" id="user_receive_newsletter_no" name="user[receive_newsletter]" value="no" checked="checked" />
def radio_button(object_name, method, tag_value, options = {})
InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_radio_button_tag(tag_value, options)
end