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

{% set modal_class = 'modal-lg' %}
{% set block = block|default(null) %}

{% block title %}
  {% if editBlock.id == 0 %}新增{% else %}设置{% endif %}编辑区
{% endblock %}

{% if editBlock.id == 0 %}
  {% set checkCodeUrl = path('admin_block_code_check_forcreate') %}
{% else %}
  {% set checkCodeUrl = path('admin_block_code_check_foredit', {id:editBlock.id}) %}
{% endif %}

{% block body %}
  <form class="form-horizontal" data-id = {{ editBlock.id }} id="block-form"  
  {% if editBlock.id == 0 %}
    action="{{ path('admin_block_create') }}"
  {% else %}
    action="{{ path('admin_block_edit', {block:editBlock.id}) }}" 
  {% endif %}  method="post">


  <div class="row form-group">
    <div class="col-md-3 control-label"><label for="code">编号</label></div>
    <div class="col-md-8 controls"> 
    <input class="form-control" type="text" id="code" value="{{editBlock.code}}" data-url="{{checkCodeUrl}}" name="code"></div>
  </div>

  <div class="row form-group">
    <div class="col-md-3 control-label"><label for="title">标题</label></div>
    <div class="col-md-8 controls"> 
    <input class="form-control" type="text" id="title" value="{{editBlock.title}}" name="title"></div>
  </div>

  <div class="row form-group">
    <div class="col-md-3 control-label"><label for="mode">编辑模式</label></div>
    <div class="col-md-8 controls"> 
      <div class="controls col-md-8 radios">
        <label><input type="radio" name="mode" value="html" {% if editBlock.mode == 'html' %}checked{% endif %}>HTML</label>
        <label><input type="radio" name="mode" value="template" {% if editBlock.mode == 'template' %}checked{% endif %}>模板</label>
      </div>
    </div>
  </div>

  <div class="row form-group" style="display:none;" id="template">
    <div class="col-md-3 control-label"><label for="template">模板内容</label></div>
    <div class="col-md-8 controls">
      <textarea id="template" name="template" class="form-control" rows="8">{{ editBlock.template }}</textarea>
      <div class="help-block">
        目前提供３种模板内容占位符，占位符在内容编辑时，会转换为编辑框，方便网站运营编辑
        <ul>
          <li>((占位符名:a)) - 举例：&lt;a href="((链接一:a))"&gt;这个是链接&lt;/a&gt;</li>
          <li>((占位符名:text)) - 举例：&lt;a href="#"&gt;(( 文本一:text ))&lt;/a&gt;</li>
          <li>((占位符名:img)) - 举例：&lt;img src="((图片一:img))" /&gt;</li>
        </ul>

      </div>
    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-3 control-label"><label for="tips">内容编辑帮助</label></div>
    <div class="col-md-8 controls">
      <textarea id="tips" name="tips" class="form-control" rows="4"></textarea>
      <div class="help-block">填写内容编辑时的帮助信息</div>
    </div>
  </div>

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

  </form>

  <script type="text/javascript">
    app.load('block/save-modal')
  </script>
{% endblock %}

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