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

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

{% block title %}
  {% if chapter %}编辑{% else %}添加{% endif %}{% if type == 'unit' %}{% if setting('default.part_name') %}{{setting('default.part_name')|default('节')}}{% else %}节{% endif %}{% else %}{% if setting('default.chapter_name') %}{{setting('default.chapter_name')|default('章')}}{% else %}章{% endif %}{% 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">{% if setting('default.part_name') %}{{setting('default.part_name')|default('节')}}{% else %}节{% endif %}标题</label>
      {% else %}
        <label for="chapter-title-field">{% if setting('default.chapter_name') %}{{setting('default.chapter_name')|default('章')}}{% else %}章{% endif %}标题</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" data-chapter="{{default.chapter_name|default('章')}}" data-part="{{default.part_name|default('节')}}">{% if chapter %}保存{% else %}添加{% endif %}</button>
{% endblock %}

{% set hideFooter = true %}
