You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
multi-model/views/articles/edit.ejs

45 lines
1.3 KiB

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<header>
<h1>Edit <%=article.title%>'s Info</h1>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/articles">Articles Index</a>
</li>
</ul>
</nav>
</header>
<main>
<h2>Article Attributes:</h2>
<form action="/articles/<%=article._id%>?_method=PUT" method="post">
<input type="text" name="title" value="<%=article.title%>"/><br/>
<textarea name="body"><%=article.body%></textarea><br/>
Choose and author:
<select name="authorId">
<% for(var currentAuthorIndex = 0; currentAuthorIndex < authors.length; currentAuthorIndex++) { %>
<%
var isAuthor = false;
for(var currentArticleIndex = 0; currentArticleIndex < authors[currentAuthorIndex].articles.length; currentArticleIndex++){
if(authors[currentAuthorIndex].articles[currentArticleIndex]._id.toString() == article._id.toString()){
isAuthor = true;
}
}
%>
<option value="<%=authors[currentAuthorIndex]._id %>" <%=(isAuthor)?'selected':''%>><%=authors[currentAuthorIndex].name %></option>
<% } %>
</select><br/>
<input type="submit" value="Update Article"/>
</form>
</main>
</body>
</html>