{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}

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

{% block title %}
  {% if chapter %}编辑{% else %}添加{% endif %}{% if type == 'unit' %}小节{% else %}章{% endif %}
{% endblock %}
{% block body %}

<form id="course-chapter-form" class="form-horizontal" method="post" {% if parentId is defined%}data-parentId="{{parentId}}" {% endif %}
  {% if chapter %}
	  action="{{ path('course_manage_chapter_edit', {courseId:course.id, chapterId:chapter.id}) }}"
	{% else %}
	  action="{{ path('course_manage_chapter_create', {id:course.id}) }}"
  {% endif %}
  >
  <div class="row form-group">
    <div class="col-md-3 control-label">
      {% if type == 'unit' %}
        <label for="chapter-title-field">小节标题</label>
      {% else %}
        <label for="chapter-title-field">章标题</label>
        {% endif %}
    </div>
    <div class="col-md-8 controls"><input id="chapter-title-field" type="text" name="title" value="{{ field_value(chapter, 'title') }}" class="form-control"></div>
  </div>
  <input type="hidden" name="type" value="{{ type }}">
</form>

<script>app.load('course-manage/chapter-modal')</script>

{% endblock %}

{% block footer %}
    <button type="button" class="btn btn-link" data-dismiss="modal">取消</button>
    <button id="course-chapter-btn" data-submiting-text="正在提交" type="submit" class="btn btn-primary" data-toggle="form-submit" data-target="#course-chapter-form">{% if chapter %}保存{% else %}添加{% endif %}</button>
{% endblock %}

{% set hideFooter = true %}
