{% extends 'TopxiaWebBundle:Course:dashboard-layout.html.twig' %}

{% set post = post|default(null) %}

{% block title %}{% if post %}编辑帖子{% else %}回复帖子{% endif %} - {{ parent() }}{% endblock %}

{% set script_controller = 'course/thread-post-form' %}

{% block dashboard_main %}

<ul class="breadcrumb">
  <li><a href="{{ path('course_threads', {id:course.id}) }}">讨论区</a></li>
  <li><a href="{{ path('course_thread_show', {courseId:thread.courseId, id:thread.id}) }}">{{ thread.title|plain_text(10) }}</a></li>
  <li class="active">编辑帖子</li>
</ul>

<form id="thread-post-form" method="post"
  {% if post %}
    action="{{ path('course_thread_post_edit', {courseId:course.id, threadId:post.threadId, id:post.id}) }}"
  {% else %}
    action="{{ path('course_thread_post', {courseId:course.id, id:post.id}) }}"
  {% endif %}
  >
  <div class="form-group">
    <div class="controls">
      {{ form_widget(form.content, {attr:{class:'form-control', rows:15, 'data-display':'内容'}}) }}
    </div>
  </div>
  <div class="form-group">
    <div class="controls clearfix">
      {{ form_rest(form) }}
      <button type="submit" class="btn btn-primary pull-right">发表</button>
      <a href="{{ path('course_threads', {id:course.id}) }}" class="btn btn-link pull-right">取消</a>
    </div>
  </div>

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

{% endblock %}
