Browse files

Clarification in an example. Grammar correction.

  • Loading branch information...
JosephPecoraro committed May 30, 2009
1 parent bf1b1e9 commit 3aeec3209c04219c3e78cce060e6c0e284e60108
Showing with 3 additions and 7 deletions.
  1. +3 −7 railties/guides/source/form_helpers.textile
@@ -211,19 +211,15 @@ h4. Binding a Form to an Object
While this is an increase in comfort it is far from perfect. If Person has many attributes to edit then we would be repeating the name of the edited object many times. What we want to do is somehow bind a form to a model object, which is exactly what +form_for+ does.
-Assume we have a controller for dealing with articles:
+Assume we have a controller for dealing with articles +app/controllers/articles_controller.rb+:
def new
@article =
-The corresponding view using +form_for+ looks like this
+The corresponding view +app/views/articles/new.html.erb+ using +form_for+ looks like this:
<% form_for :article, @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %>
@@ -584,7 +580,7 @@ h4. Dealing with Ajax
Unlike other forms making an asynchronous file upload form is not as simple as replacing +form_for+ with +remote_form_for+. With an Ajax form the serialization is done by JavaScript running inside the browser and since JavaScript cannot read files from your hard drive the file cannot be uploaded. The most common workaround is to use an invisible iframe that serves as the target for the form submission.
-h3. Customising Form Builders
+h3. Customizing Form Builders
As mentioned previously the object yielded by +form_for+ and +fields_for+ is an instance of FormBuilder (or a subclass thereof). Form builders encapsulate the notion of displaying form elements for a single object. While you can of course write helpers for your forms in the usual way you can also subclass FormBuilder and add the helpers there. For example

0 comments on commit 3aeec32

Please sign in to comment.