<%= form_for(@topic) do |f| %>
  <% if @topic.errors.any? %>
    <div id="error_explanation">
      <h2><%=t 'activerecord.errors.template.header', :count => @topic.errors.size, :model => @topic.class.model_name.human %></h2>
      <h4><%=t 'activerecord.errors.template.body', :count => @topic.errors.size %></h4>
      <ul>
        <% @topic.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :board %><br />
    <!--<%= f.select :category_id, Board.all.collect{|board|[board.name, board.id]} %>-->
    <%= f.hidden :category_id %>
  </div>
  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.fields_for :posts, @post do |post_fields| %>
      <%= post_fields.text_area :content, :id => :fastpostmessage %>
      <div class="field">
        <%= post_fields.label "附件" %><br />
        <%= post_fields.fields_for :attachments do |attachment_form| %>
          <div class="asset field">
            <% if attachment_form.object.data.exists? %>
              <%= attachment_form.object.data.original_filename %>
            <% else %>
              <%= attachment_form.file_field :data %>
            <% end %>
          </div>
        <% end %>
      </div>
    <% end %>
    <script type="text/javascript">
      $(document).ready(function()	{
        $('#fastpostmessage').markItUp(mySettings);
      });
    </script>
  </div>
  <!--<div class="field">
  <%= f.label :readperm %><br />
  <%= f.text_field :readperm %>
  </div>
  <div class="field">
  <%= f.label :private %><br />
  <%= f.check_box :private %>
  </div>-->
  <%= f.hidden_field :displayorder %>
  <%= f.hidden_field :category_type %>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
