forked from geddy/geddy
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added form partial to the mongo example
- Loading branch information
Techwraith
committed
Mar 13, 2012
1 parent
f01c2d5
commit c3b5119
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<% | ||
var isUpdate = params.action == 'edit' | ||
, formTitle = isUpdate ? 'Update this To Do Item' : 'Create a new To Do Item' | ||
, action = isUpdate ? '/todos/' + todo.id + '?_method=PUT' : '/todos' | ||
, deleteAction = isUpdate ? '/todos/' + todo.id + '?_method=DELETE' : '' | ||
, btnText = isUpdate ? 'Update' : 'Add' | ||
, doneStatus = isUpdate ? 'checked' : '' | ||
, titleValue = isUpdate ? todo.title : '' | ||
, errors = params.errors; | ||
%> | ||
<form id="todo-form" class="form-horizontal" action="<%= action %>" method="POST"> | ||
<fieldset> | ||
<legend><%= formTitle %></legend> | ||
<div class="control-group"> | ||
<label for="title" class="control-label">Title</label> | ||
<div class="controls"> | ||
<input type="text" class="span6" placeholder="enter title" name="title" value='<%= titleValue %>'/> | ||
<% if (errors) { %> | ||
<p> | ||
<% for (var p in errors) { %> | ||
<div><%= errors[p]; %></div> | ||
<% } %> | ||
</p> | ||
<% } %> | ||
</div> | ||
</div> | ||
<% if (isUpdate) { %> | ||
<div class="control-group"> | ||
<label for="status">Status</label> | ||
<div class="controls"> | ||
<select name="status"> | ||
<option>open</option> | ||
<option>done</option> | ||
</select> | ||
</div> | ||
</div> | ||
<% } %> | ||
<div class="form-actions"> | ||
<input type="submit" class="btn btn-primary" value="<%= btnText %>"/> | ||
<% if (isUpdate) { %> | ||
<button type="submit" formaction="<%= deleteAction %>" formmethod="POST" class="btn btn-danger">Remove</button> | ||
<% } %> | ||
</div> | ||
</fieldset> | ||
</form> | ||
|