Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Shared form for example-app views.

  • Loading branch information...
commit f0ae5a9dd940f0fcb64e1ffd8cbda19b7fc2d9c9 1 parent 7af9d71
@mde mde authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 examples/todo_app/app/views/todos/_form.html.ejs
View
31 examples/todo_app/app/views/todos/_form.html.ejs
@@ -0,0 +1,31 @@
+ <%
+ var isUpdate = params.action == 'edit'
+ , action = isUpdate ? '/todos/' + todo.id + '?_method=PUT': '/todos'
+ , btnText = isUpdate ? 'Update' : 'Add'
+ , doneStatus = isUpdate ? 'checked' : ''
+ , errors = params.errors;
+ %>
+ <form id="todo-form" action="<%= action %>" method="POST">
+ <% if (errors) {
+ for (var p in errors) { %>
+ <div><%= errors[p]; %></div>
+ <% }
+ }
+ %>
+ <div>
+ <% if (isUpdate) { %>
+ <%= todo.title %>
+ <input type="hidden" class="span6" placeholder="<%= todo.title %>" name="title"/>
+ <% }
+ else {%>
+ <input type="text" class="span6" placeholder="enter title" name="title"/>
+ <% } %>
+ </div>
+ <div>
+ <input type="checkbox" name="status" <%= doneStatus %> /> Done
+ </div>
+ <div>
+ <input type="submit" class="btn btn-primary" value="<%= btnText %>">
+ </div>
+ </form>
+
Please sign in to comment.
Something went wrong with that request. Please try again.