_form.html.erb 1.33 KB
<%= 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]}] %>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<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 %>