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


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

{% block title %}
  {% if editBlock.id == 0 %}{{'新增'|trans}}{% else %}{{'设置'|trans}}{% endif %}{{'编辑区'|trans}}
{% 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', {blockTemplateId:editBlock.id}) }}" 
  {% endif %}  method="post">


  <div class="row form-group">
    <div class="col-md-3 control-label"><label for="code">{{'编号'|trans}}</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">{{'标题'|trans}}</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">{{'编辑模式'|trans}}</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 %}>{{'模板'|trans}}</label>
      </div>
    </div>
  </div>

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

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

  <div class="row form-group">
    <div class="col-md-3 control-label"><label for="tips">{{'内容编辑帮助'|trans}}</label></div>
    <div class="col-md-8 controls">
      <textarea id="tips" name="tips" class="form-control" rows="4"></textarea>
      <div class="help-block">{{'填写内容编辑时的帮助信息'|trans}}</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">{{'取消'|trans}}</button>
    <button id="block-save-btn" data-submiting-text="{{'正在提交'|trans}}" type="submit" class="btn btn-primary" data-toggle="form-submit" data-target="#block-form">{{'保存'|trans}}</button>
{% endblock %}
