Created
October 25, 2010 20:10
-
-
Save ddemaree/645639 to your computer and use it in GitHub Desktop.
Rails 3 ERb template showing a simple syntax for doing REST forms without unnecessary DOM class/ID cruft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% form_tag @user = User.new do %> | |
<% fields_for @user do |user_form| %> | |
<div class="field"> | |
<label>Name</label> | |
<%= user_form.text_field :name %> | |
</div> | |
<% end %> | |
<% end %> | |
<% form_tag @user = User.first, :method => :put do %> | |
<% fields_for @user do |user_form| %> | |
<div class="field"> | |
<label>Name</label> | |
<%= user_form.text_field :name %> | |
</div> | |
<% end %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form accept-charset="UTF-8" action="/users" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="wHmerRLGE0nrTsQZ6q02Qw/YvX9uwQvTWrrmYQ1rZQY=" /></div> <div class="field"> | |
<label>Name</label> | |
<input id="user_name" name="user[name]" size="30" type="text" /> | |
</div> | |
</form> | |
<form accept-charset="UTF-8" action="/users/1" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="wHmerRLGE0nrTsQZ6q02Qw/YvX9uwQvTWrrmYQ1rZQY=" /></div> <div class="field"> | |
<label>Name</label> | |
<input id="user_name" name="user[name]" size="30" type="text" value="David Demaree" /> | |
</div> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment