aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/active_record_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-15 18:57:17 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-15 18:57:17 +0000
commitc81af992e84169e7e462a99dd1f86b96eff7d345 (patch)
tree149ba4c7bd2afb5b412a691efb4d511673de82b4 /actionpack/lib/action_view/helpers/active_record_helper.rb
parent31901a5939d5bfad8ae543724de8de3a069ab26a (diff)
downloadrails-c81af992e84169e7e462a99dd1f86b96eff7d345.tar.gz
rails-c81af992e84169e7e462a99dd1f86b96eff7d345.tar.bz2
rails-c81af992e84169e7e462a99dd1f86b96eff7d345.zip
Added the option of passing a block to ActiveRecordHelper#form in order to add more to the auto-generated form #469 [dom@sisna.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@422 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/active_record_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/active_record_helper.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index 6855fa49c5..82c6d1cd81 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -49,6 +49,13 @@ module ActionView
# <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /><br />
# <input type='submit' value='Sign' />
# </form>
+ #
+ # It's also possible to add additional content to the form by giving it a block, such as:
+ #
+ # form("entry", :action => "sign") do |form|
+ # form << content_tag("b", "Department")
+ # form << collection_select("department", "id", @departments, "id", "name")
+ # end
def form(record_name, options = {})
record = instance_eval("@#{record_name}")
@@ -59,9 +66,9 @@ module ActionView
id_field = record.new_record? ? "" : InstanceTag.new(record_name, "id", self).to_input_field_tag("hidden")
- %(<form action="#{action}" method="post">#{id_field}) +
- all_input_tags(record, record_name, options) +
- %(<input type="submit" value="#{submit_value}" /></form>)
+ formtag = %(<form action="#{action}" method="post">#{id_field}) + all_input_tags(record, record_name, options)
+ yield formtag if block_given?
+ formtag + %(<input type="submit" value="#{submit_value}" /></form>)
end
# Returns a string containing the error message attached to the +method+ on the +object+, if one exists.