Skip to content

Commit

Permalink
Added more information about inputs :for in README.
Browse files Browse the repository at this point in the history
Signed-off-by: Justin French <justin@indent.com.au>
  • Loading branch information
josevalim authored and justinfrench committed Mar 16, 2009
1 parent 87647f1 commit 9997ce6
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.textile
Expand Up @@ -14,7 +14,7 @@ One day, I finally had enough, so I opened up my text editor, and wrote a DSL fo
<%= form.input :body %>
<%= form.input :section %>
<%= form.input :publication_state, :as => :radio %>
<%= form.input :author %>
<%= form.input :category %>
<%= form.input :allow_comments, :label => "Allow commenting on this article" %>
<% end %>

Expand All @@ -25,6 +25,11 @@ 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 :for => :author do |author_form| %>
<%= form.input :first_name %>
<%= form.input :last_name %>
<% end %>

<% form.buttons do %>
<%= form.commit_button %>
<% end %>
Expand Down Expand Up @@ -151,13 +156,26 @@ If you want to customize the label text, or render some hint text below the fiel
<% end %>
</pre>

Nested forms (Rails 2.3) are also supported:
Nested forms (Rails 2.3) are also supported. You can do it in the Rails way:

<pre>
<% semantic_form_for @post do |post| %>
<%= post.inputs %>

<%= post.semantic_fields_for :author do |author| %>
<%= author.inputs %>
<%= author.inputs :first_name, :last_name %>
<%= end %>

<%= post.buttons %>
<% end %>
</pre>

Or in the formtastic way:

<pre>
<% semantic_form_for @post do |post| %>
<%= post.inputs %>
<%= post.inputs :first_name, :last_name, :for => :author %>
<%= post.buttons %>
<% end %>
</pre>
Expand Down

0 comments on commit 9997ce6

Please sign in to comment.