{% extends 'old-bootstrap-modal-layout.html.twig' %}
{% set block = block|default(null) %}

{% block title %}{{'编辑内容'|trans}}{% endblock %}


{% set modal_class = 'modal-lg' %}

{% block body %}

<h5>{{'编辑区名称：'|trans}}{{block.title}}</h5>

<form id="block-form"  {% if block.mode == 'template' %}class="form-horizontal" {% endif %} action="{{ path('admin_block_update', {blockTemplateId:block.id}) }}" method="post">
  {% if block.mode == 'html' %}
  <div class="form-group">
      <div class="controls">
        <textarea class="form-control" id="blockContent" rows="10" name="content" data-role="editor-field" style="z-index:1000;">{{ block.content }}</textarea>
        <input type="hidden" name="blockId" value="{{ block.blockId|default() }}">
        <input type="hidden" name="blockTemplateId" value="{{ block.blockTemplateId|default() }}">
        <input type="hidden" name="code" value="{{ block.code|default() }}">
        <input type="hidden" name="data" value="{{ block.data|default() }}">
      </div>
  </div>
  {% endif %}
  <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
</form>
{% if block.mode == 'html' %}
<form id="block-image-upload-form" action="{{ path('file_upload', {group:'default'}) }}" method="post" enctype="multipart/form-data">
  <input class="btn btn-default btn-sm" type="file" name="file" value="{{'上传'|trans}}" style="display:inline-block;">
  <input type="hidden" name="token" value="{{ upload_token('block', 'image') }}" />
  <button class="btn btn-default btn-sm">{{'上传图片'|trans}}</button>
  <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
</form>
{% endif %}

<div class="mbm mtl"><strong>{{'编辑帮助'|trans}}</strong></div>
<div class="text-info">{{ block.tips|nl2br }}</div>

<div class="mbm mtl"><strong>{{'变更记录'|trans}}</strong></div>
{% include 'admin/block/block-history-data.html.twig'  %}
{% endblock %}

{% block footer %}
  <button type="button" class="btn btn-link" data-dismiss="modal">{{'取消'|trans}}</button>
  <button id="block-update-btn" data-submiting-text="{{'正在提交'|trans}}" type="submit" class="btn btn-primary" data-toggle="form-submit" data-target="#block-form">{{'保存'|trans}}</button>
  <script type="text/javascript">app.load('block/update');</script>
{% endblock %}
