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


{% set modal_class = 'modal-lg' %}
{% block title %}{% if category.id %}{{'编辑栏目'|trans}}{% else %}{{'添加栏目'|trans}}{% endif %}{% endblock %}

{% block body %}
	<form id="category-form" class="form-horizontal" action="{% if category.id %}{{ path('admin_article_category_edit', {id:category.id}) }}{% else %}{{ path('admin_article_category_create') }}{% endif %}" method="post">
		<div class="form-group">
			<label class="col-md-2 control-label" for="category-name-field">{{'栏目名称'|trans}}</label>
			<div class="col-md-8 controls">
				<input class="form-control" id="category-name-field" type="text" name="name" value="{{ category.name }}" tabindex="1">
			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="category-code-field">{{'栏目编码'|trans}}</label>
			<div class="col-md-8 controls">
				<input class="form-control" id="category-code-field" type="text" name="code" value="{{ category.code }}" data-url="{{ path('admin_article_category_checkcode', {exclude:category.code}) }}" tabindex="2">
				<div class="help-block">{{'生成列表、资讯时使用，例如news、bbs等'|trans}}</div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="category-parentId-field">{{'父栏目'|trans}}</label>
			<div class="col-md-8 controls">
				<select class="form-control category-select" id="category-parentId-field" type="text" name="parentId" tabindex="2" data-url="{{ path('admin_article_category_checkparentid', {currentId:category.id}) }}">
					<option value="0">--{{'选择栏目'|trans}}--</option>
					{% for tree in categoryTree %}
					<option value="{{ tree.id }}" {% if tree.id == category.parentId  %}selected{% endif %}>{% for i in 1..(tree.depth-1) if tree.depth > 1 %}　{% endfor %}{{ tree.name }}</option>
					{% endfor %}
				</select>
			</div>		
		</div>

		<div style="display:none;" class="form-group">
			<label class="col-md-2 control-label" for="category-publishArticle-field">{{'允许发布资讯'|trans}}</label>
			<div class="controls radios col-md-8"><label>
					<input  id="category-publishArticle-field" type="radio" name="publishArticle" tabindex="0" value=1 {% if category.publishArticle ==1 %}checked{% endif %}>{{'是'|trans}}</label>
				<label>
					<input  id="category-publishArticle-field" type="radio" name="publishArticle" tabindex="0" value=0 {% if category.publishArticle !=1 %}checked{% endif %}>{{'否'|trans}}
				</label>	
				
			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="category-seoTitle-field">{{'SEO标题'|trans}}</label>
			<div class="col-md-8 controls">
				<input class="form-control" id="category-seoTitle-field" type="text" name="seoTitle" value="{{ category.seoTitle }}" tabindex="4">
				<div class="help-block"></div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="category-seoKeyword-field">{{'SEO关键字'|trans}}</label>
			<div class="col-md-8 controls">
				<input class="form-control" id="category-seoKeyword-field" type="text" name="seoKeyword" value="{{ category.seoKeyword }}" tabindex="4">
				<div class="help-block"></div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="category-seoDesc-field">{{'SEO描述'|trans}}</label>
			<div class="col-md-8 controls">
				<input class="form-control" id="category-seoDesc-field" type="text" name="seoDesc" value="{{ category.seoDesc }}" tabindex="4">
				<div class="help-block"></div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="category-published-field">{{'启用'|trans}}</label>
			<div class="controls radios col-md-8">
				<label><input id="category-published-field" type="radio" name="published" tabindex="0" value=1 {% if category.published ==1 %}checked{% endif %}>{{'是'|trans}}</label>
				<label><input id="category-published-field" type="radio" name="published" tabindex="0" value=0 {% if category.published !=1 %}checked{% endif %}>{{'否'|trans}}</label>
				<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('article/category/save-modal'); </script>
{% endblock %}

{% block footer %}
	{% if category.id %}
		<button type="button" class="btn btn-default pull-left delete-category" data-url="{{ path('admin_article_category_delete', {id:category.id}) }}" tabindex="5"><i class="glyphicon glyphicon-trash"></i> {{'删除'|trans}}</button>
	{% else %}

	{% endif %}
  	<button type="button" class="btn btn-link" data-dismiss="modal" tabindex="6">{{'取消'|trans}}</button>
	<button id="category-save-btn" data-submiting-text="{{'正在提交'|trans}}" type="submit" class="btn btn-primary" data-toggle="form-submit" data-target="#category-form" tabindex="4">{{'添加'|trans}}</button>
{% endblock %}