Permalink
Browse files

Create a Post form with tag helpers

  • Loading branch information...
xmonkey committed Dec 5, 2012
1 parent 76a2d58 commit af05a8d5ccfd22fdcd5021a5a45986498cc07e81
Showing with 15 additions and 1 deletion.
  1. +15 −1 app/views/posts/new.html.erb
@@ -1,6 +1,7 @@
<h2>Add new Post</h2>
+<h3> Form based on form_for </h3>
<%= form_for (@post) do |f| %>
- <div class="field">
+ <div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
@@ -12,3 +13,16 @@
<%= f.submit %>
</div>
<% end %>
+
+<h3> Form based on form_tag </h3>
+<%= form_tag(@post) do -%>
+ <div class="field">
+ <%= label_tag 'title' %><br />
+ <%= text_field_tag 'post[title]' %><br />
+ </div>
+ <div class="field">
+ <%= label_tag 'url' %><br />
+ <%= text_field_tag 'post[url]' %><br />
+ </div>
+ <div><%= submit_tag 'Create post' %></div>
+<% end -%>

0 comments on commit af05a8d

Please sign in to comment.