Permalink
Browse files

use real objects in :for and fields_for examples, fixes #561

  • Loading branch information...
1 parent eff38a1 commit a3713e84e122187e10de28d11ed1bb1679e9f5f4 @justinfrench committed May 30, 2011
Showing with 10 additions and 10 deletions.
  1. +4 −4 README.textile
  2. +2 −2 lib/formtastic/helpers/fieldset_wrapper.rb
  3. +4 −4 lib/formtastic/helpers/inputs_helper.rb
View
@@ -36,7 +36,7 @@ One day, I finally had enough, so I opened up my text editor, and wrote a DSL fo
<%= form.input :url_title, :required => false %>
<% end %>
- <%= form.inputs :name => "Author", :for => :author do |author_form| %>
+ <%= form.inputs :name => "Author", :for => @article.author do |author_form| %>
<%= author_form.input :first_name %>
<%= author_form.input :last_name %>
<% end %>
@@ -192,7 +192,7 @@ Nested forms are also supported (don't forget your models need to be setup corre
<pre>
<%= semantic_form_for @post do |form| %>
<%= form.inputs :title, :body, :created_at %>
- <%= form.semantic_fields_for :author do |author| %>
+ <%= form.semantic_fields_for @post.author do |author| %>
<%= author.inputs :first_name, :last_name, :name => "Author" %>
<% end %>
<%= form.buttons %>
@@ -204,7 +204,7 @@ Or the Formtastic way with the @:for@ option:
<pre>
<%= semantic_form_for @post do |form| %>
<%= form.inputs :title, :body, :created_at %>
- <%= form.inputs :first_name, :last_name, :for => :author, :name => "Author" %>
+ <%= form.inputs :first_name, :last_name, :for => @post.author, :name => "Author" %>
<%= form.buttons %>
<% end %>
</pre>
@@ -214,7 +214,7 @@ When working in has many association, you can even supply @"%i"@ in your fieldse
<pre>
<%= semantic_form_for @post do |form| %>
<%= form.inputs %>
- <%= form.inputs :name => 'Category #%i', :for => :categories %>
+ <%= form.inputs :name => 'Category #%i', :for => @post.categories %>
<%= form.buttons %>
<% end %>
</pre>
@@ -8,11 +8,11 @@ module FieldsetWrapper
# Generates a fieldset and wraps the content in an ordered list. When working
# with nested attributes, it allows %i as interpolation option in :name. So you can do:
#
- # f.inputs :name => 'Task #%i', :for => :tasks
+ # f.inputs :name => 'Task #%i', :for => @project.tasks
#
# or the shorter equivalent:
#
- # f.inputs 'Task #%i', :for => :tasks
+ # f.inputs 'Task #%i', :for => @project.tasks
#
# And it will generate a fieldset for each task with legend 'Task #1', 'Task #2',
# 'Task #3' and so on.
@@ -142,7 +142,7 @@ module InputsHelper
# <% semantic_form_for @user do |f| %>
# <%= f.inputs :name, :email %>
#
- # <% f.inputs :for => :profile do %>
+ # <% f.inputs :for => @user.profile do %>
# <%= profile.input :biography %>
# <%= profile.input :twitter_name %>
# <%= profile.input :shoe_size %>
@@ -151,9 +151,9 @@ module InputsHelper
#
# The `:for` option also works with short hand syntax:
#
- # <% semantic_form_for @post do |form| %>
+ # <% semantic_form_for @user do |form| %>
# <%= f.inputs :name, :email %>
- # <%= f.inputs :biography, :twitter_name, :shoe_size, :for => :profile %>
+ # <%= f.inputs :biography, :twitter_name, :shoe_size, :for => @user.profile %>
# <% end %>
#
# {#inputs} will always create a new `<fieldset>` wrapping, so only use it when it makes sense
@@ -233,7 +233,7 @@ module InputsHelper
# <%= f.input :name ... %>
# <%= f.input :email ... %>
# <% end %>
- # <%= f.inputs :for => :profile do |profile| %>
+ # <%= f.inputs :for => @user.profile do |profile| %>
# <%= profile.input :user ... %>
# <%= profile.input :categories ... %>
# <% end %>

0 comments on commit a3713e8

Please sign in to comment.