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

{% set modalSize = 'large' %}

{% block title %}{% if announcement|default(null) %}编辑{% else %}新增{% endif %}公告{% endblock %}
{% block body %}

<form id="announcement-create-form" class="form-horizontal" method="post" action="{% if announcement|default(null) %}{{ path('admin_announcement_edit',{id:announcement.id})}}{% else %}{{ path('admin_announcement_create')}}{% endif %}">

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="title">公告内容</label>
    </div>
    <div class="col-md-8 controls">
      <input type="text" id="title"  name="title" class="form-control" value="{% if announcement|default(null) %}{{announcement.title}}{% endif %}">
    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="url">内容链接</label>
    </div>
    <div class="col-md-8 controls">
      <input type="text" id="url"  name="url" class="form-control" value="{{ announcement.url|default('')}}">
      <p class="help-block">以"http://"或"https://"开头</p>
    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="startTime">发布时间</label>
    </div>
    <div class="col-md-8 controls" style="z-index:2000;">
      <input type="text" id="startTime"  name="startTime" class="form-control" value="{% if announcement|default(null) %}{{announcement.startTime|date("Y-m-d H:i")}}{% endif %}">
    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="endTime">结束时间</label>
    </div>
    <div class="col-md-8 controls" style="z-index:2000;">
      <input type="text" id="endTime"  name="endTime" class="form-control" value="{% if announcement|default(null) %}{{announcement.endTime|date("Y-m-d H:i")}}{% endif %}">
    </div>
  </div>

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

</form>
{% endblock %}

{% block footer %}
  <button id="announcement-create-btn" data-submiting-text="正在提交" type="submit" class="btn btn-primary pull-right" data-toggle="form-submit" data-target="#announcement-create-form">提交</button>
  <button type="button" class="btn btn-link pull-right" data-dismiss="modal">取消</button>
  <script>app.load('announcement/create-modal')</script>
{% endblock %}