{% extends 'base.html' %}

{% block content %}
<div class="card">
  <div class="card-header">
    <h3 class="card-title">{{ form_title }}</h3>
  </div>
  <form role="form" method="post">
    <div class="card-body col-md-6">
      {% for field in form %}
        <div class="form-group {{field.name}} {% if field.errors %}has-error{% endif %}">
          {{ field.label }} {% if field.flags.required %}<span class="text-danger">*</span>{% endif %}
          {{ field(class_="form-control") }}
          {% for message in field.errors %}
            <div class="text-danger">{{ message }}</div>
          {% endfor %}
        </div>
      {% endfor %}
    </div>
    <div class="card-footer">
      <input type="submit" value="{% if btn_name %}{{btn_name}}{% else %}Save{% endif %}" class="btn btn-primary"/>
    </div>
  </form>
</div>
<script>
  $(function() {
    if ($('#code_editor').length) {
      $('.card-body').removeClass('col-md-6');
      var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('code_editor'), {
          lineNumbers: true,
          matchBrackets: true
      });
    }
  });
</script>
{% endblock %}