_form.html.erb
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<span><%= f.label :title, '标题' %></span>
<%= f.text_field :title, placeholder: '标题 30字以内 不能为空' %>
</div>
<div class="field">
<span><%= f.label :flag, '别名' %></span>
<%= f.text_field :flag, placeholder: '可以不填让系统自动生成' %>
</div>
<div class="field">
<span><%= f.label :words, '关键词' %></span>
<%= f.text_field :words, placeholder: '英文逗号隔开,' %>
</div>
<div class="field">
<span><%= f.label :chan, '频道' %></span>
<%= f.select :chan, Hash[Post::CATE.map{|k, v| [v[:name], k]}] %>
<span><%= f.label :cate, '类别' %></span>
<%= f.select :cate, Post::CATE[@post.try(:chan) || Post::CATE.keys.first][:cate].invert %>
</div>
<% if params[:source] == 'edit' %>
<%= f.text_area :detail, style: "border: 1px solid #c9d8db;width:100%;height:400px;" %>
<% else %>
<%= render 'source', f: f %>
<% end %>
<br>
<%= f.submit %>
<% end %>