diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-01-16 02:01:57 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-01-16 02:01:57 +0000 |
commit | b812b236876ab7a6bd1f3e58a1aa71847394f3a1 (patch) | |
tree | 28e65251aee0a1007bec37b03c4ae2b5c41ff293 /actionpack/lib/action_view/helpers | |
parent | 8a71f870093ccdfa0b04e318cca0f517576be380 (diff) | |
download | rails-b812b236876ab7a6bd1f3e58a1aa71847394f3a1.tar.gz rails-b812b236876ab7a6bd1f3e58a1aa71847394f3a1.tar.bz2 rails-b812b236876ab7a6bd1f3e58a1aa71847394f3a1.zip |
Make render :partial recognise form builders and use the _form partial. Closes #10814 [djanowski]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8646 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index f67a040149..d2835a2438 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -32,6 +32,15 @@ module ActionView # <input name="commit" type="submit" value="Create" /> # </form> # + # If you are using a partial for your form fields, you can use this shortcut: + # + # <% form_for :person, @person, :url => { :action => "create" } do |f| %> + # <%= render :partial => f %> + # <%= submit_tag 'Create' %> + # <% end %> + # + # This example will render the <tt>people/_form</tt> partial, setting a local variable called <tt>form</tt> which references the yielded FormBuilder. + # # The <tt>params</tt> object created when this form is submitted would look like: # # {"action"=>"create", "controller"=>"persons", "person"=>{"first_name"=>"William", "last_name"=>"Smith"}} @@ -153,6 +162,12 @@ module ActionView # <%= check_box_tag "person[admin]", @person.company.admin? %> # <% end %> # + # In this case, if you use this: + # + # <%= render :partial => f %> + # + # The rendered template is <tt>people/_labelling_form</tt> and the local variable referencing the form builder is called <tt>labelling_form</tt>. + # # In many cases you will want to wrap the above in another helper, so you could do something like the following: # # def labelled_form_for(record_or_name_or_array, *args, &proc) |