Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Create a Post form with tag helpers

  • Loading branch information...
commit af05a8d5ccfd22fdcd5021a5a45986498cc07e81 1 parent 76a2d58
@xmonkey authored
Showing with 15 additions and 1 deletion.
  1. +15 −1 app/views/posts/new.html.erb
View
16 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 -%>
Please sign in to comment.
Something went wrong with that request. Please try again.