{% extends 'TopxiaWebBundle:Class:layout.html.twig' %}

{% set script_controller = 'class-thread/thread-form' %}

{% block class_main %}

<form id="thread-form" class="form-vertical" method="post" 
  {% if thread|default(null) %}
    action="{{ path('class_thread_edit', {classId:class.id, threadId:thread.id}) }}"
  {% else %}
    action="{{ path('class_thread_create', {classId:class.id}) }}"
    {% endif %}
  >

  <div class="form-group">
    <div class="controls">
      <input id="thread-title-field" type="text" name="title" class="form-control" placeholder="标题" value="{{ thread.title|default('') }}">
    </div>
  </div>

  <div class="form-group">
    <div class="controls">
      <textarea id="thread-content-field" class="form-control" name="content" rows="15" placeholder="正文">{{ thread.content|default('') }}</textarea>
    </div>
  </div>

  <div class="form-group clearfix">
    <div class="controls pull-right">
      {% if thread|default(null) %}
        <a href="{{ path('class_thread_show', {classId:thread.classId, threadId:thread.id}) }}" class="btn btn-link">取消</a>
        <button type="submit" class="btn btn-primary btn-fat">保存</button>
      {% else %}
        <a href="{{ path('class_threads', {classId:class.id}) }}" class="btn btn-link">取消</a>
        <button type="submit" class="btn btn-primary">发表</button>
      {% endif  %}
    </div>
  </div>

  <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
</form>

{% endblock %}