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


{% set modal_class = 'modal-lg' %}
{% block title %}{% if category.id %}{{'admin.article_setting.category.edit'|trans}}{% else %}{{'admin.article_setting.category.create'|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">{{'admin.article_setting.category.name'|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">{{'admin.article_setting.category.code'|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">{{'admin.article_setting.category.code.tips'|trans}}</div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="category-parentId-field">{{'admin.article_setting.category.parent_category'|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">--{{'admin.article_setting.category.choose'|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">{{'admin.article_setting.category.allow_publish'|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 %}>{{'site.datagrid.radios.yes'|trans}}</label>
				<label>
					<input  id="category-publishArticle-field" type="radio" name="publishArticle" tabindex="0" value=0 {% if category.publishArticle !=1 %}checked{% endif %}>{{'site.datagrid.radios.no'|trans}}
				</label>

			</div>
		</div>

		<div class="form-group">
			<label class="col-md-2 control-label" for="category-seoTitle-field">{{'admin.article_setting.category.seo_title'|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">{{'admin.article_setting.category.seo_keywords'|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">{{'admin.article_setting.category.seo_description'|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">{{'admin.article_setting.category.publish'|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 %}>{{'site.datagrid.radios.yes'|trans}}</label>
				<label><input id="category-published-field" type="radio" name="published" tabindex="0" value=0 {% if category.published !=1 %}checked{% endif %}>{{'site.datagrid.radios.no'|trans}}</label>
				<div class="help-block">{{'admin.article_setting.category.publish.tips'|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> {{'form.btn.delete'|trans}}</button>
	{% else %}

	{% endif %}
  	<button type="button" class="btn btn-link" data-dismiss="modal" tabindex="6">{{'form.btn.cancel'|trans}}</button>
	<button id="category-save-btn" data-submiting-text="{{'form.btn.submit.submiting'|trans}}" type="submit" class="btn btn-primary" data-toggle="form-submit" data-target="#category-form" tabindex="4">{{'form.btn.add'|trans}}</button>
{% endblock %}
