{% extends 'Comitium5DesignerBundle:Form:base_form_div_layout.html.twig' %}

{% block form_row -%}

	{% set view_types = {
	'facebook': {
	'ico': 'facebook',
	'help': '',
	'label': 'cs_common_base.form.type.facebook.label',
	'placeholder': 'cs_common_base.form.type.facebook.placeholder'
	},
	'twitter': {
	'ico': 'twitter',
	'help': '',
	'label': 'cs_common_base.form.type.twitter.label',
	'placeholder': 'cs_common_base.form.type.twitter.placeholder'
	},
	'linkedin': {
	'ico': 'linkedin',
	'help': '',
	'label': 'cs_common_base.form.type.linkedin.label',
	'placeholder': 'cs_common_base.form.type.linkedin.placeholder'
	},
	'google-plus': {
	'ico': 'google-plus',
	'help': '',
	'label': 'cs_common_base.form.type.google-plus.label',
	'placeholder': 'cs_common_base.form.type.google-plus.placeholder'
	},
	'instagram': {
		'ico': 'instagram',
		'help': '',
		'label': 'cs_common_base.form.type.instagram.label',
		'placeholder': 'cs_common_base.form.type.instagram.placeholder'
	},
	'pinterest': {
		'ico': 'pinterest',
		'help': '',
		'label': 'cs_common_base.form.type.pinterest.label',
		'placeholder': 'cs_common_base.form.type.pinterest.placeholder'
	},
	'twitch': {
		'ico': 'twitch',
		'help': '',
		'label': 'cs_common_base.form.type.twitch.label',
		'placeholder': 'cs_common_base.form.type.twitch.placeholder'
	},
	'username': {
	'ico': 'user',
	'help': '',
	'label': 'cs_common_base.form.type.username.label',
	'placeholder': 'cs_common_base.form.type.username.placeholder'
	},
	'name': {
	'ico': 'user',
	'help': '',
	'label': 'cs_common_base.form.type.name.label',
	'placeholder': 'cs_common_base.form.type.name.placeholder'
	},
	'surnames': {
	'ico': 'user',
	'help': '',
	'label': 'cs_common_base.form.type.surnames.label',
	'placeholder': 'cs_common_base.form.type.surnames.placeholder'
	},
	'email': {
	'ico': 'envelope',
	'help': '',
	'label': 'cs_common_base.form.type.email.label',
	'placeholder': 'cs_common_base.form.type.email.placeholder'
	},
	'mobile': {
	'ico': 'mobile',
	'help': '',
	'label': 'cs_common_base.form.type.mobile.label',
	'placeholder': 'cs_common_base.form.type.mobile.placeholder'
	},
	'fax':{
	'ico' : 'fax',
	'label': 'cs_common_base.form.type.fax.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.fax.placeholder'
	},
	'password': {
	'ico': 'lock',
	'help': '',
	'label': 'cs_common_base.form.type.password.label',
	'placeholder': 'cs_common_base.form.type.password.placeholder'
	},
	'repeat_password': {
	'ico': 'lock',
	'help': '',
	'label': 'cs_common_base.form.type.repeat_password.label',
	'placeholder': 'cs_common_base.form.type.repeat_password.placeholder'
	},
	'description': {
	'ico': 'comment',
	'help': '',
	'label': 'cs_common_base.form.type.description.label',
	'placeholder': 'cs_common_base.form.type.description.placeholder'
	},
	'title': {
	'ico': 'comment',
	'help': '',
	'label': 'cs_common_base.form.type.title.label',
	'placeholder': 'cs_common_base.form.type.title.placeholder'
	},
	'locale': {
	'label': 'cs_common_base.form.type.locale.label',
	'ico': '',
	'help': '',
	'placeholder': ''
	},
	'content_type': {
	'label': 'cs_common_base.form.type.content_type.label',
	'ico': '',
	'help': '',
	'placeholder': ''
	},
	'group': {
	'label': 'cs_common_base.form.type.group.label',
	'ico': '',
	'help': '',
	'placeholder': ''
	},
	"parent": {
	'label': 'cs_common_base.form.type.parent.label',
	'ico': '',
	'help': '',
	'placeholder': 'cs_common_base.form.type.parent.placeholder'
	},
	"enabled": {
	'label': 'cs_common_base.form.type.enabled.label',
	'ico': '',
	'help': '',
	'placeholder': ''
	},
	"meta_title": {
	'label': 'cs_common_base.form.type.meta_title.label',
	'ico': '',
	'help': 'cs_common_base.form.type.meta_title.help',
	'placeholder': 'cs_common_base.form.type.meta_title.placeholder'
	},
	"meta_description": {
	'label': 'cs_common_base.form.type.meta_description.label',
	'ico': '',
	'help': 'cs_common_base.form.type.meta_description.help',
	'placeholder': 'cs_common_base.form.type.meta_description.placeholder'
	},
	"meta_keywords": {
	'label': 'cs_common_base.form.type.meta_keywords.label',
	'ico': '',
	'help': 'cs_common_base.form.type.meta_keywords.help',
	'placeholder': 'cs_common_base.form.type.meta_keywords.placeholder'
	},
	"slug": {
	'label': 'cs_common_base.form.type.slug.label',
	'ico': '',
	'help': 'cs_common_base.form.type.slug.help',
	'placeholder': 'cs_common_base.form.type.slug.placeholder'
	},
	"canonical": {
	'label': 'cs_common_base.form.type.canonical.label',
	'ico': '',
	'help': 'cs_common_base.form.type.canonical.help',
	'placeholder': 'cs_common_base.form.type.canonical.placeholder'
	},
	"categories": {
	'label': 'cs_common_base.form.type.categories.label',
	'ico': '',
	'help': 'cs_common_base.form.type.categories.help',
	'placeholder': 'cs_common_base.form.type.categories.placeholder'
	},
	"tags": {
	'label': 'cs_common_base.form.type.tags.label',
	'ico': '',
	'help': '',
	'placeholder': 'cs_common_base.form.type.tags.placeholder'
	},
	"question": {
	'label': 'cs_common_base.form.type.question.label',
	'ico': '',
	'help': '',
	'placeholder': 'cs_common_base.form.type.question.placeholder'
	},
	"answer": {
	'label': 'cs_common_base.form.type.answer.label',
	'ico': '',
	'help': '',
	'placeholder': 'cs_common_base.form.type.answer.placeholder'
	},
	"votes": {
	'label': 'cs_common_base.form.type.votes.label',
	'ico': '',
	'help': '',
	'placeholder': 'cs_common_base.form.type.votes.placeholder'
	},
	'spinner': {
	'ico': 'twitter',
	'help': '',
	'label': 'cs_common_base.form.type.twitter.label',
	'placeholder': 'cs_common_base.form.type.twitter.placeholder'
	},
	'tick': {
	'ico': '',
	'help': '',
	'label': '',
	'placeholder': ''
	},
	'yes-no': {
	'ico': '',
	'help': '',
	'label': '',
	'placeholder': ''
	},
	'image': {
	'ico' : '',
	'help': 'cs_common_base.form.type.image.help',
	'label': 'cs_common_base.form.type.image.label',
	'placeholder': 'cs_common_base.form.type.image.placeholder'
	},
	'middle_name': {
	'ico': 'user',
	'help': 'cs_common_base.form.type.middle_name.help',
	'label': 'cs_common_base.form.type.middle_name.label',
	'placeholder': 'cs_common_base.form.type.middle_name.placeholder'
	},
	'last_name': {
	'ico': 'user',
	'help': 'cs_common_base.form.type.last_name.help',
	'label': 'cs_common_base.form.type.last_name.label',
	'placeholder': 'cs_common_base.form.type.last_name.placeholder'
	},
	'birthday': {
	'ico' : '',
	'label': 'cs_common_base.form.type.birthday.label',
	'help': '',
	'placeholder': ''
	},
	'job':{
	'ico' : '',
	'label': 'cs_common_base.form.type.job.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.job.placeholder'
	},
	'studies':{
	'ico' : '',
	'label': 'cs_common_base.form.type.studies.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.studies.placeholder'
	},
	'address':{
	'ico' : '',
	'label': 'cs_common_base.form.type.address.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.address.placeholder'
	},
	'postal_code':{
	'ico' : '',
	'label': 'cs_common_base.form.type.postal_code.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.postal_code.placeholder'
	},
	'city':{
	'ico' : '',
	'label': 'cs_common_base.form.type.city.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.city.placeholder'
	},
	'province':{
	'ico' : '',
	'label': 'cs_common_base.form.type.province.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.province.placeholder'
	},
	'country':{
	'ico' : '',
	'label': 'cs_common_base.form.type.country.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.country.placeholder'
	},
	'identity':{
	'ico' : '',
	'label': 'cs_common_base.form.type.identity.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.identity.placeholder'
	},
	'website':{
	'ico' : '',
	'label': 'cs_common_base.form.type.website.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.website.placeholder'
	},
	'locale':{
	'ico' : '',
	'label': 'cs_common_base.form.type.default_language.label',
	'help': '',
	'placeholder': ''
	},
	'contact_groups':{
	'ico' : '',
	'label': 'cs_common_base.form.type.contact_groups.label',
	'help': '',
	'placeholder': 'cs_common_base.form.type.contact_groups.placeholder'
	}

	} %}

	{% if view_type is defined and view_type is not null and view_types[view_type] is defined %}
		{% set thisViewType = view_types[view_type] %}
	{% else %}
		{% set thisViewType = {'label': label, 'ico': ico, 'help': help, 'placeholder': ''} %}
	{% endif %}

    {% set ico = (ico or ico is not null) ? ico : thisViewType['ico'] %}
    {% set label = label ? label : thisViewType['label'] %}
    {% set placeholder = placeholder ? placeholder : thisViewType['placeholder'] %}
    {% set help = help ? help : thisViewType['help'] %}


	<div class="form-group {{ (form.vars.errors|length) ? 'has-error' }}">

		{% if expanded is defined %}
			{% if expanded == true %}
				{% set widget_attr = attr|merge({ class: 'radio-list' }) %}
			{% else %}
				{% set widget_attr = attr|merge({ class: attr.class is defined ? attr.class ~ ' form-control select2' : 'form-control select2' }) %}
			{% endif %}
		{% else %}
			{% set widget_attr = attr|merge({ class: 'form-control' ~ (attr.class is defined ? ' ' ~ attr.class : ' col-md-5') }) %}
		{% endif %}

		{% set attr = container_attr|merge({ class: (container_attr.class is defined ? container_attr.class : ' col-md-6') }) %}

        {% set label_attr = label_attr|merge({ class: 'control-label' ~ (label_attr.class is defined ? ' ' ~ label_attr.class : ' col-md-3')  }) %}
        {% if expanded is defined and expanded == true %}
            <label class="col-md-3 control-label">{{ translatable ? label|trans : label }}{% if required == true%} <span class="required" aria-required="true">*</span>{% endif %}</label>
        {% else %}
            {{- form_label(form, label, { label_attr: label_attr }) -}}
        {% endif %}

        <div {{ block('widget_container_attributes') }}>
            {% if ico is not empty %}
            <div class="input-icon">
                <i class="fa fa-{{ ico }} "></i>
                {% endif %}

                {% if placeholder is not empty %}
                    {% set widget_attr = widget_attr|merge({ 'placeholder': placeholder }) %}
                {% endif %}

                {{- form_widget(form, { attr: widget_attr }) -}}

                {% if help is not empty %}

                    <span class="help-block">{{ (translatable ? help|trans : help)|raw }}</span>
                {% endif %}

                {% if ico is not empty %}
            </div>
            {% endif %}
            {% if hideErros is defined %}
                {#dont show errors#}
            {% else %}
                {{- form_errors(form) -}}
            {% endif %}
        </div>
    </div>
    {{- form_widget(form) -}}
{%- endblock form_row %}

{% block form_label -%}
    {% if label is not same as(false) %}
        {%- if not compound -%}
            {% set label_attr = label_attr|merge({'for': id}) %}
        {%- endif -%}
        {%- if required -%}
            {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
        {%- endif -%}
        {%- if label is empty -%}
            {% set label = name|humanize %}
        {%- endif -%}

        {% set text = translatable ? label|trans({}, translation_domain): label %}

        <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
			{{ text|raw }}
			{%- if required -%}
				<span class="required" aria-required="true">*</span>
			{%- endif -%}
			{% if label_attr.help is defined %}
				<span class="info">{{ translatable ? label_attr.help|trans({}, translation_domain) : label_attr.help }}</span>
			{% endif %}
		</label>

    {%- endif %}
{%- endblock form_label %}

{% block form_widget %}
	{% if compound %}
        {{- block('form_widget_compound') -}}
    {% else %}
        {{- block('form_widget_simple') -}}
    {% endif %}
{% endblock %}

{% block form_widget_simple -%}
    {%- set type = type|default('text') -%}
    {% set attr = attr|merge({ class: 'form-control' ~ (attr.class is defined ? ' ' ~ attr.class : '') }) %}
    <input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{%- endblock form_widget_simple %}

{% block button_widget -%}
    {% import '@Comitium5Designer/Common/buttons.html.twig' as btn %}
    {% if label is empty -%}
        {% set label = name|humanize %}
    {%- endif -%}
    {% set attr = attr|merge({ class: "btn mainBtn" ~ (attr.class is defined ? ' ' ~ attr.class : '') }) %}
    <button type="{{ type|default('button') }}" {{ block('button_attributes') }}>
        {{ label|trans({}, translation_domain) }}
    </button>
{%- endblock button_widget %}

{% block widget_container_attributes -%}
    {%- for attrname, attrvalue in attr -%}
        {{- " " -}}
        {%- if attrname in ['placeholder', 'title'] -%}
            {{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
        {%- elseif attrvalue is same as(true) -%}
            {{- attrname }}="{{ attrname }}"
        {%- elseif attrvalue is not same as(false) -%}
            {{- attrname }}="{{ attrvalue }}"
        {%- endif -%}
    {%- endfor -%}
{%- endblock widget_container_attributes %}

{% block form_errors %}
    {% spaceless %}
        {% if errors|length > 0 %}
            {% for error in errors %}
                <span class="help-block">{{ error.message }}</span>
            {% endfor %}
        {% endif %}
    {% endspaceless %}
{% endblock form_errors %}

{% block choice_widget %}
    {% spaceless %}
        {% if expanded %}
            <div {{ block('widget_container_attributes') }}>
                {% for child in form %}
                    {{ form_widget(child) }}
                {% endfor %}
            </div>
        {% else %}
			<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
                {% if empty_value is not none %}
					<option value="">{{ translatable ? empty_value|trans : empty_value }}</option>
                {% endif %}
                {% if preferred_choices|length > 0 %}
                    {% set options = preferred_choices %}
                    {{ block('choice_widget_options') }}
                    {% if choices|length > 0 and separator is not none %}
                        <option disabled="disabled">{{ separator }}</option>
                    {% endif %}
                {% endif %}
                {% set options = choices %}
                {{ block('choice_widget_options') }}
            </select>
        {% endif %}
    {% endspaceless %}
{% endblock choice_widget %}

{% block choice_widget_options -%}

	{%- macro print(category) -%}
		{% spaceless %}
			{% if category.parent %}
				{{ _self.print(category.parent) ~ ' > ' }}
			{% endif %}
			{{ category.defaultLang.name }}
		{% endspaceless %}
	{%- endmacro -%}

	{% for group_label, choice in options %}

		{%- if choice is iterable -%}
            <optgroup label="{{ group_label|trans({}, translation_domain) }}">
                {% set options = choice %}
                {{- block('choice_widget_options') -}}
            </optgroup>
        {%- else -%}

			{% if form.vars.view_type == 'categories' %}
				<option {% if choice.data %}data-extended="{{ (choice.data.parent ? _self.print(choice.data.parent) : '') }}" data-enabled="{{ choice.data.enabled ? 'true' : 'false' }}" {% endif %}value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>
					{{ translatable ? choice.label|trans|capitalize : choice.label|capitalize }}
				</option>
			{% elseif form.vars.view_type == 'workflow_state' %}
				<option data-name="{{ choice.data.name }}" value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>
					{{ ("workflow.states." ~ choice.label )|trans }}
				</option>
			{% elseif form.vars.view_type == 'fields' %}
				{% if  choice.data.type != constant('ComitiumSuite\\Components\\Fields\\Model\\FieldType::LOOP') or choice is selectedchoice(value) %}
					<option data-field="{{ choice.data.type|default('') }}" value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ translatable ? choice.label|trans : choice.label }}</option>
				{% endif %}
			{% elseif form.vars.view_type == "tags" %}
				<option value="{{ choice.value }}"
					data-extended="{{ choice.data.defaultLang.description }}"
					data-enabled="{{ choice.data.enabled ? 'true' : 'false' }}"
					data-enabled-text="{{ "cs_core.label.disabled"|transchoice(2) }}"
					{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>
					{{ translatable ? choice.label|trans : choice.label }}
				</option>
			{% else %}
                {% set attr = choice.attr %}
            	<option value="{{ choice.value }}" {{ block('attributes') }} {% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ translatable ? choice.label|trans : choice.label }}</option>
			{% endif %}
		{%- endif -%}
    {% endfor %}
{%- endblock choice_widget_options %}


{% block checkbox_widget -%}
    {# @TODO Required false to accept true or false values #}

	{% set textOn  = 'ON' %}
	{% set textOff = 'OFF' %}

    {% if view_type is defined %}
        {% if view_type == 'tick' %}
            {% set textOn  = "<i class='fa fa-check'></i>" %}
            {% set textOff = "<i class='fa fa-times'></i>" %}
        {% elseif view_type == 'yes-no' %}
            {% set textOn  = 'cs_core.label.yes'|trans %}
            {% set textOff = 'cs_core.label.no'|trans  %}
		{% elseif view_type == 'correct' %}
			{% set textOn  = 'cs_core.label.correct'|trans %}
			{% set textOff = 'cs_core.label.incorrect'|trans  %}
        {% endif %}
    {% endif %}

	{% set required = false %}
	{% set attr = attr|merge({ class: "make-switch" ~ (attr.class is defined ? ' ' ~ attr.class|replace({'form-control':''}) : '') }) %}

    <input type="checkbox" {{ block('widget_attributes') }} data-on-text="{{ textOn }}" data-off-text="{{ textOff }}"{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %}>

{%- endblock checkbox_widget %}

{% block radio_widget %}
    <label class="radio-inline" for="{{ id }}">
        <input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />{{ label|trans }}
    </label>
{% endblock radio_widget %}

{% block asset_widget %}
    {% import 'Comitium5DesignerBundle:Common/macro:asset.html.twig' as asset %}
    {% set library_url = url('designer_assets_library_page',
        {
            page: 1,
            type: asset_type,
            outter: true,
			contentLocale: app.request.get('contentLocale')
        })
    %}
    <div id="{{ form.vars.id }}_container" class="tabbable-custom assets assets-widget">
        <ul{% if not multiple and form.vars.value is not empty %} style="display: none;" {% endif %} class="nav nav-tabs">
            <li class="active">
                <a href="#{{ form.vars.id }}_tab_upload" data-toggle="tab"><i class="fa fa-desktop"></i>
                    {{ 'cs_assets.widget.tabs.upload'|trans }}
                </a>
            </li>
            {% if from_library %}
                <li>
                    <a href="#{{ form.vars.id }}_tab_library" data-toggle="tab" data-load="ajax" data-url="{{ library_url }}"><i class="fa fa-folder-open"></i>
                        {{ 'cs_assets.widget.tabs.library'|trans }}
                    </a>
                </li>
            {% endif %}
            {% if allow_external and asset_type == 'video' %}
                <li>
                    <a href="#{{ form.vars.id }}_tab_external" data-toggle="tab">
                        <i class="fa fa-link"></i>
                        {{ ('cs_assets.widget.tabs.external_' ~ asset_type)|trans  }}
                    </a>
                </li>
            {% endif %}
        </ul>
        <div{% if not multiple and form.vars.value is not empty %} style="display: none;" {% endif %} class="tab-content">
            {{ block('asset_widget_upload') }}
            {% if from_library %}
                {{ block('asset_widget_library') }}
            {% endif %}
			{% if allow_external and asset_type == 'video' %}
                {{ block('asset_widget_external') }}
            {% endif %}
        </div>
        <div class="cs-selected-assets">
            {% if multiple %}
                {% for entity in form.vars.data %}
                    {{ block('asset_collection_item') }}
                {% endfor %}
            {% else %}
                {% set entity = form.vars.data %}
                {% if entity is not empty %}
                    {{ block('asset_collection_item') }}
                {% endif %}
            {% endif %}
        </div>
	</div>
{% endblock %}

{% block asset_widget_external %}
<div class="tab-pane" id="{{ form.vars.id }}_tab_external">
	<div class="form-group">
		<label class="control-label required">{{ "cs_assets.widget.label.upload_external_video"|trans }} <span class="required" aria-required="true">*</span></label>
        <div class="input-group">
			<input data-type="external_video_upload" type="text" class="form-control asset-external-input" name="name" placeholder="{{ ('cs_assets.widget.placeholder.upload_external_' ~ asset_type)|trans }}">
			<span class="input-group-btn">
				<a data-type="external_video_upload_submit" href="#" class="btn green asset-add-external">{{ 'cs_core.action.add.default'|trans }}</a>
			</span>
		</div>
    </div>
</div>
{% endblock asset_widget_external %}

{% block asset_widget_upload %}
    <!-- Tab Upload -->
    <div class="tab-pane active" id="{{ form.vars.id }}_tab_upload">
		{% for locale in get_locales() %}
			<div data-upload-locale data-lang-code="{{ locale.code }}" data-lang-name="{{ locale.name }}"  data-default="{{ app.request.get("contentLocale", "") }}"></div>
		{% endfor %}
        <div class="{{ form.vars.id }}_tab_upload">
            <fieldset {% spaceless %}
                id="{{ form.vars.id }}_dropzone"
                class="dropzone assets-dropzone"
                data-url="{{ url('designer_assets_upload') }}"
                data-dropzone-type="{{ asset_type }}"
                data-name="{{ form.vars.full_name }}"
                data-type="{{ form.vars.parent_type }}"
                data-multiple="{{ multiple ? 'true' : 'false' }}"
                data-content-type="{{ form.vars.content_type is defined ? form.vars.content_type : '' }}"
                data-content-type="{{ form.vars.content_type is defined ? form.vars.content_type : '' }}"
                {% if mime_types %}
                    data-mime-types="{{ mime_types|e('html_attr') }}"
                {% endif %}
                    {% endspaceless %}>

                <div class="dz-default dz-message">
                    {{ 'cs_assets.messages.dropzone'|trans|raw }}
                </div>

                {% set type = 'hidden' -%}
                {% set attr = attr|merge({ 'data-asset': '' }) %}
                {% if multiple %}
                    {% for value in form.vars.value %}
                        {{ block('form_widget_simple') }}
                    {% endfor %}
                {% else %}
                    {% set value = form.vars.value %}
                    {{ block('form_widget_simple') }}
                {% endif %}
            </fieldset>
        </div>
    </div>
    <!-- /Tab Upload -->
{% endblock %}

{% block asset_widget_library %}
    <div class="tab-pane tab-asset-library loading" id="{{ form.vars.id }}_tab_library">
		<div class="text-center">
			<img src="{{ asset("bundles/comitium5designer/statics/designer-statics/images/layout_img/pagination-loader.gif") }}"/>
		</div>
        {#{{ render_hinclude(library_url) }}#}
    </div>
{% endblock %}

{% block asset_collection_item %}
    <div id="{{ 'library-asset-' ~ entityData.id ~ '_selected' }}" class="row asset-wrapper" data-id-content="{{ entityData.id }}">
        <div class="image-inner">
            <div class="col-md-3 col-xs-4 image asset-image">
                {% if entityData.type is not empty %}
                    {% set asset_type = entityData.type %}
                {% endif %}
                <img src="{{ asset.print_thumbnail(entityData, asset_type) }}" alt="{{ entityData.title }}"/>
                <span class="opts">
					<a href="{{ path('admin_assets_edit', {id : entity.id, ignoreReferer: 1, contentLocale: app.request.get("contentLocale", "") }) }}" class="btn btn-icon-only btn-circle blue" target="_blank"><i class="fa fa-pencil"></i></a>
					<a href="#" class="btn btn-icon-only btn-circle blue" target="_blank" style="display:none"><i class="fa fa-pencil"></i></a>
                    <a href="#" class="btn btn-icon-only btn-circle yellow-gold" data-action="unselect"><i class="fa fa-minus"></i></a>
                </span>
			</div>
			<div class="col-md-9 col-xs-8 image-info">
                {% set locales = get_locales() %}
				<div class="form-group">
		            <div class="input-group" data-lang-field-container>
                        {% if locales|length > 1 %}
							<div class="input-group-btn" data-lang-field-delete>
								<select id="search-order" class="bs-select form-control no-select2" data-style="clean" data-lang-field-selector>
									{% for locale in locales %}
{#										{% set title = "" %}#}
{#										{% for lang in entityData.getLangs %}#}
{#											{% if lang.locale.code == locale.code %}#}
{#												{% set title = lang.title|default("")  %}#}
{#											{% endif %}#}
{#										{% endfor -%}#}
										<option data-lang-code="{{ locale.code }}" data-lang-name="{{ locale.name }}" data-lang-title="{{ entityData.title }}" data-default="{{ entityData.localeCode }}" value="{{ locale.code }}" {{ locale.code == entityData.localeCode ? "selected": "" }}>{{ locale.name }}</option>
									{%- endfor %}
								</select>
							</div>
                        {% endif %}
		                <div class="input-icon asset-title">
		                    <i class="fa fa-pencil"></i>
		                    <input type="text" class="form-control" data-entity="title" data-seo-image="text" placeholder="Untitled" value="{{ entityData.title }}">
		                </div>
		            </div>
		        </div>

			</div>
		</div>
	</div>
{% endblock %}

{%- block spinner_row -%}

	{% set attr = attr|merge({'class':'spinner-input'}) %}

	{% spaceless %}
		<div class="form-group">
			<div {{ block("widget_container_attributes") }}>
				{{ form_label(form) }}
				<div class="gf-spinner">
					<div class="input-group" style="width:150px;">
						{{ form_widget(form, {attr : attr, disabled:disabled}) }}
						<div class="spinner-buttons input-group-btn">
							<button type="button" class="btn spinner-up default">
								<i class="fa fa-angle-up"></i>
							</button>
							<button type="button" class="btn spinner-down default">
								<i class="fa fa-angle-down"></i>
							</button>
						</div>
					</div>
				</div>
				{% if help %}<p class="help-block">{{ (translatable ? help|trans : help)|raw }}</p>{% endif %}
			</div>
		</div>
	{% endspaceless %}
{% endblock %}

{% block double_row %}
	{% spaceless %}
		<div class="form-group">

			{{ form_label(form) }}

			<div {{ block("widget_container_attributes") }}>
				<div class="input-inline">
					<div class="input-group bootstrap-touchspin">

						<span class="input-group-btn"></span>

						{{ form_widget(form, {attr:{'class':'touchspin-input', 'style':'display: block'}, disabled:disabled}) }}

						<span class="input-group-addon bootstrap-touchspin-postfix">%</span>

						<span class="input-group-btn"></span>
					</div>
				</div>
				{% if help %}<p class="help-block">{{ (translatable ? help|trans : help)|raw }}</p>{% endif %}
			</div>
		</div>
	{% endspaceless %}
{% endblock %}

{% block metadata_row %}

	{% set labelClass     = form.vars.label_attr.class is defined ? form.vars.label_attr.class : '' %}
	{% set containerClass = form.vars.container_attr.class is defined ? form.vars.container_attr.class : '' %}

	{{ form_row(form.metaTitle, {view_type:'meta_title',label_attr: {class: labelClass}, container_attr: {class:containerClass}, attr: {'data-slugable': '#' ~ form.slug.vars.id, 'data-url' : path('cs_utils_get_slug', { class: get_class(form.vars.data|default(''))  }) } } ) }}
	{{ form_row(form.metaDescription, {view_type:'meta_description', label_attr: {class: labelClass}, container_attr: {class:containerClass}} ) }}
	{{ form_row(form.metaKeywords, {view_type:'meta_keywords', label_attr: {class: labelClass}, container_attr: {class:containerClass}, attr: { class: 'tags', 'data-text': 'seo.placeholder.keywords'|trans } } ) }}
	{{ form_row(form.slug, {view_type:'slug', label_attr: {class: labelClass}, container_attr: {class:containerClass}} ) }}
	{{ form_row(form.canonical, {view_type:'canonical', label_attr: {class: labelClass}, container_attr: {class:containerClass} } ) }}

{% endblock %}

{% block categories_tags_row %}
    {% form_theme form.categories 'AdminBundle:Form:categories_tags.html.twig'%}
    {{ form_row(form.categories, { view_type: 'categories', expanded: false, attr: { class: 'no-select2' } }) }}
    {{ form_row(form.tags, { view_type: 'tags', expanded: false, attr: { class: 'no-select2' } }) }}
{% endblock %}


{% block locations_widget %}
	<div class="cs_map_search col-md-12" data-add="location">
		<div class="form-group col-md-10 col-xs-12">
			<div class="input-group">
				<input type="text" class="form-control" name="{{ form.searchAddress.vars.name }}" id="{{ form.searchAddress.vars.id }}" value="{{ form.searchAddress.vars.value }}" />
				<span class="input-group-addon"><i class="fa fa-search"></i></span>
			</div>
		</div>
	</div>
	<div class="clearfix"></div>
	<div id="cs_map" class="cs_map col-md-12"></div>
	<div class="clearfix"></div>
	<div class="cs_map_locations col-md-12">

		<h4 class="semibold">{{ "cs_cms.maps.form.collection.title"|trans }}</h4>
		<table class="table table-bordered">
			<thead>
			<tr>
				<th class="col-md-2 hidden-xs hidden-sm">{{ "cs_cms.maps.form.collection.type"|trans }}</th>
				<th class="col-md-8">{{ "cs_cms.maps.form.collection.name"|trans }}</th>
				<th class="col-md-2 text-center">{{ "cs_cms.maps.form.collection.actions"|trans }}</th>
			</tr>
			</thead>
			{% set mapLocations = form.mapLocations.vars.prototype %}
            {% set index = '' %}
			<tbody data-prototype="{{ block('locations_mapLocations')|e }}" data-button-prototype="{{ block('addLocationsButton')|e }}">
			{% for child in form.mapLocations %}
				{% set mapLocations = child %}
                {% set index = loop.index0 %}
				{{ block('locations_mapLocations') }}
			{% endfor %}
			</tbody>
		</table>
	</div>
{% endblock %}

{#{% block locations_mapLocations %}#}
{#    #}{#{{ ld(mapLocations.vars.data) }}#}
{#    {% set title, type, address, postalCode, city, province, country, jsonData, zoom = '', '', '', '', '', '', '', '', '' %}#}
{#    {% set types = ['', 'cs_cms.maps.types.point'] %}#}
{#    {% if mapLocations.vars.data %}#}

{#		{% set mapTreeData = get_tree_data_from_location(mapLocations.vars.data.location) %}#}

{#        {% if mapLocations.vars.data.type %}#}
{#            {% set type = types[mapLocations.vars.data.type] %}#}
{#        {% endif %}#}

{#		{% if mapLocations.vars.data.address %}#}
{#            {% set address = mapLocations.vars.data.address %}#}
{#        {% endif %}#}

{#		{% if mapTreeData.postalcode is defined %}#}
{#            {% set postalCode = mapTreeData.postalcode.name|default("") %}#}
{#        {% endif %}#}

{#		{% if mapTreeData.city is defined %}#}
{#            {% set city = mapTreeData.city.name|default("") %}#}
{#        {% endif %}#}

{#        {% if mapTreeData.province is defined %}#}
{#            {% set province = mapTreeData.province.name|default("") %}#}
{#        {% endif %}#}

{#        {% if mapTreeData.country is defined %}#}
{#            {% set country = mapTreeData.country.name|default("") %}#}
{#        {% endif %}#}

{#        {% if mapLocations.vars.data.title %}#}
{#            {% set title = mapLocations.vars.data.title %}#}
{#        {% endif %}#}

{#        {% if mapLocations.vars.data.data %}#}
{#            {% set jsonData = mapLocations.vars.data.data %}#}
{#        {% endif %}#}

{#        {% if mapLocations.vars.data.zoom %}#}
{#            {% set zoom = mapLocations.vars.data.zoom %}#}
{#        {% endif %}#}
{#    {% endif %}#}

{#    <tr {% if index is defined or index is not same as(0) %} data-element-index="{{ index }}" {% endif %} data-id-input="{{ mapLocations.vars.id }}" >#}
{#        <td class="hidden-xs hidden-sm">#}
{#            <span class="info-icon"><i class="fa fa-map-marker"></i></span>#}
{#            {{ type|trans }}#}
{#        </td>#}
{#        <td>#}
{#            <a href="#" data-plugin="editable" data-for="{{ mapLocations.vars.id }}_title" data-type="text" data-enablefocus="true" data-pk="1" data-original-title="" data-set-location-title >{{ title }}</a>#}
{#            <input type="hidden" data-field-update="title" id="{{ mapLocations.vars.id }}_title" value="{{ title }}" />#}
{#        </td>#}
{#        <td class="text-center">#}
{#            <span class="opts">#}
{#                <a href="javascript:void(0)" title="" class="location-form-edit-location btn btn-icon-only btn-circle blue"><i class="fa fa-pencil"></i></a>#}
{#                <a href="javascript:void(0)" title="" class="location-form-delete-location btn btn-icon-only btn-circle yellow-gold"><i class="fa fa-minus"></i></a>#}
{#            </span>#}
{#        </td>#}
{#    </tr>#}
{#    <tr style="display:none;" {% if index is not empty or index is same as(0) %} data-element-index="{{ index }}" {% endif %} data-id-input="{{ mapLocations.vars.id }}"  >#}
{#        <td colspan="3">#}
{#            <div class="col-md-4">#}
{#                <div class="form-group">#}
{#                    <label for="{{ mapLocations.vars.id }}_address" class="control-label3">{{ "cs_cms.maps.form.labels.address"|trans }}</label>#}
{#                    <input type="text" data-field-update="address" class="form-control" id="{{ mapLocations.vars.id }}_address" value="{{ address }}">#}
{#                </div>#}
{#            </div>#}
{#            <div class="col-md-2">#}
{#                <div class="form-group">#}
{#                    <label for="{{ mapLocations.vars.id }}_postal_code" class="control-label3">{{ "cs_cms.maps.form.labels.postal_code"|trans }}</label>#}
{#                    <input type="text" class="form-control" id="{{ mapLocations.vars.id }}_postal_code" disabled="disabled" value="{{ postalCode }}">#}
{#                </div>#}
{#            </div>#}
{#            <div class="col-md-2">#}
{#                <div class="form-group">#}
{#                    <label for="{{ mapLocations.vars.id }}_city" class="control-label3">{{ "cs_cms.maps.form.labels.city"|trans }}</label>#}
{#                    <input type="text" class="form-control" id="{{ mapLocations.vars.id }}_city" disabled="disabled" value="{{ city }}">#}
{#                </div>#}
{#            </div>#}
{#            <div class="col-md-2">#}
{#                <div class="form-group">#}
{#                    <label for="{{ mapLocations.vars.id }}_province" class="control-label3">{{ "cs_cms.maps.form.labels.province"|trans }}</label>#}
{#                    <input type="text" class="form-control" id="{{ mapLocations.vars.id }}_province" disabled="disabled" value="{{ province }}">#}
{#                </div>#}
{#            </div>#}
{#            <div class="col-md-2">#}
{#                <div class="form-group">#}
{#                    <label for="{{ mapLocations.vars.id }}_country" class="control-label3">{{ "cs_cms.maps.form.labels.country"|trans }}</label>#}
{#                    <input type="text" class="form-control" id="{{ mapLocations.vars.id }}_country" disabled="disabled" value="{{ country }}">#}
{#                </div>#}
{#            </div>#}
{#            <div style="display:none">#}
{#                <input type="hidden" id="{{ mapLocations.vars.id }}_data" data-field-update="data" value="{{ jsonData|json_encode }}" />#}
{#                <input type="hidden" id="{{ mapLocations.vars.id }}_zoom" value="{{ zoom }}" />#}
{#                {{ form_row(mapLocations) }}#}
{#            </div>#}
{#        </td>#}
{#    </tr>#}
{#{% endblock %}#}

{% block addLocationsButton %}
	<div class="col-md-2 col-xs-12">
		<button title="Add location" class="btn defaultBtn"><i class="fa fa-map-marker"></i>{{ "cs_cms.maps.form.labels.add_location"|trans }}</button>
	</div>
{% endblock %}

{% block calendar_row %}
	{% if widget_type == 'infobox' %}
		{{ block('infobox_calendar_row') }}
	{% else %}
		{{ block('common_form_calendar_row') }}
	{% endif %}
{% endblock %}

{% block common_form_calendar_row %}
	<div class="form-group {{ (form.vars.errors|length) ? 'has-error' }}">
		{% set labelClass = label_attr.class is defined ? container_attr.class : 'col-md-3' %}

		{{- form_label(form, label, { label_attr: {class:'control-label ' ~ labelClass } }) -}}

		<div class="{{ container_attr.class is defined ? container_attr.class : 'col-md-4' }}">

			{% if widget_type == 'hours' %}
				<div class="input-group date form_datetime" data-date="{{ 'now'|date("d/m/Y H:i") }}">

					{{- form_widget(form, {attr:{size:16}}) -}}

					<span class="input-group-btn">
                    <button class="btn default date-reset" type="button"><i class="fa fa-times"></i></button>
                </span>
					<span class="input-group-btn">
                    <button class="btn default date-set" type="button"><i class="fa fa-calendar"></i></button>
                </span>
				</div>
			{% endif %}

			{# here another types of calendar #}

			{% if help %}<p class="help-block">{{ (translatable ? help|trans : help)|raw }}</p>{% endif %}

			{% if form.vars.errors|length %}
				{% for error in form.vars.errors %}
					<p class="help-block has-error">{{ error.message|trans }}</p>
				{% endfor %}
			{% endif %}
		</div>
	</div>
{% endblock %}

{% block infobox_calendar_row %}
	{% set labelClass = label_attr.class is defined ? container_attr.class : 'col-md-3' %}

	{{- form_label(form, label, { label_attr: {class:'control-label ' ~ labelClass } }) -}}

	<div class="{{ container_attr.class is defined ? container_attr.class : 'col-md-4' }}">
		<div id="{{ calendar_id }}" class="input-group date" data-date="{{ form.vars.data ? form.vars.data : 'now'|date("d/m/Y H:i") }}">

			{{- form_widget(form, {attr:{size:16, readonly: true} }) -}}

			{% if clear_allowed %}
				<span class="input-group-btn">
                        <button class="btn default date-reset" type="button"><i class="fa fa-times"></i></button>
                    </span>
			{% endif %}
			<span class="input-group-btn">
				<button class="btn default date-set" type="button"><i class="fa fa-calendar"></i></button>
			</span>
		</div>

		{% if help %}<p class="help-block">{{ (translatable ? help|trans : help)|raw }}</p>{% endif %}

		{% if form.vars.errors|length %}
			{% for error in form.vars.errors %}
				<p class="help-block has-error">{{ error.message|trans }}</p>
			{% endfor %}
		{% endif %}
	</div>
{% endblock %}

{# @TODO Revisar per afegir datetime també#}
{% block date_range_widget %}
	<div class="col-md-6">
		<div class="input-group input-medium date-picker input-daterange input-daterange-container" data-date="{{ "now" | date('d/m/Y') }}"
		     data-date-format="dd/mm/yyyy">
			{% for element in form.iterator %}
				{{ form_widget(element, {placeholder: '', label: false }) }}
				{% if loop.index0 == 0 %}
					<span class="input-group-addon">{{ 'cs_core.label.date_range_mid'|trans }}</span>
				{% endif %}
			{% endfor %}
		</div>
		<!-- /input-group -->
		{% if form.vars.required %}
			{#@TODO Posar els textos en un altre lloc#}
			{#@TODO Mirar por que se coloca mal, sacar de dentro del col-md-6#}
			<span class="help-block">{{ 'cms_classifieds.classifieds.help.dates'|trans }} </span>
		{% else %}
			<span class="help-block">{{ 'cms_classifieds.classifieds.search.dates'|trans }} </span>
		{% endif %}
	</div>
{% endblock %}

{% block suggest_widget %}
    {% set attr = attr|merge({
		'data-id': id,
		'data-separator': separator,
		'data-suggest': '',
		'data-url': url,
		'data-property': property,
		'data-allow-clear': allow_clear,
		'data-limit': limit,
		'data-multiple': multiple,
		'data-dropdown-css-class': dropdownCssClass,
		'data-auto-initialize': autoInitialize,
		'data-label-properties': labelProperties,
		'data-only-published': onlyPublished,
		'data-content-type': content_type
	}) %}
	{{ block('form_widget_simple') }}
{% endblock suggest_widget %}

{% block multiple_subsite_suggest_widget %}
	{% set attr = attr|merge({
        'data-id': id,
        'data-suggest': '',
        'data-url': url,
        'data-property': property,
        'data-allow-clear': allow_clear,
        'data-limit': limit,
        'data-multiple': multiple,
        'data-dropdown-css-class': dropdownCssClass,
        'data-auto-initialize': autoInitialize,
        'data-label-properties': labelProperties,
        'data-only-published': onlyPublished,
        'data-subsites': subsites|join(","),
		'data-is-multiple-subsite-suggest': isMultipleSubsiteSuggest,
		'data-content-type': content_type,
		'data-separator': separator
    }) %}

    <div class="input-group">
		<div class="input-group-btn">
			<select class="bs-select no-select2" data-subsite-select data-style="default">
				<option value="">{{ "related_content.suggest.all_subsites"|trans }}</option>
				{% for name,acronym in subsites %}
				<option value="{{ acronym }}">{{ name }}</option>
				{% endfor %}
			</select>
		</div>
        {{ block('form_widget_simple') }}
    </div>
{% endblock multiple_subsite_suggest_widget %}

{% block external_database_suggest_widget %}

	{% set attr = attr|merge({
		'data-suggest': '',
		'data-type': 'external_db',
		'data-url': url,
		'data-conn': string_connection,
		'data-suggest-query': suggest_query,
		'data-multiple': multiple,
		'data-dropdown-css-class': dropdownCssClass,
		'data-auto-initialize': autoInitialize,
		'data-separator': separator,
		'data-query_type': queryType,
		'data-allow-clear': allow_clear
	}) %}
	{{ block('form_widget_simple') }}
{% endblock external_database_suggest_widget %}

{#{%- block content_search_row -%}#}

{#    {%  set related = form.vars.data %}#}
{#	{%  set referencedEntity = related ? build_uuid_entity(related.relatedUuid, related.relatedClass) : null%}#}

{#    <tr class="portlet portlet-sortable" data-collection="related-content" id="{{ form.vars.id|default('') }}"  data-contend-search-id="{{ referencedEntity.selfContentType|default('') ~ "-" ~ referencedEntity.id|default('') }}">#}

{#		<td class="hidden-md hidden-xs hidden-sm" data-set-related-id>{{ referencedEntity.id|default('') }}</td>#}

{#        {% if referencedEntity.selfContentType is defined %}#}
{#            <td class="hidden-xs hidden-sm">#}
{#				<span class="info-icon"><i class="{{ ico(referencedEntity) }}"></i></span>{{ (ico_trans_key(referencedEntity))|trans|raw }}#}
{#			</td>#}
{#        {% else %}#}
{#            <td class="hidden-xs hidden-sm" data-set-type></td>#}
{#        {% endif %}#}

{#		<td>#}
{#            {% set text = 'related_content.elements.title_placeholder'|trans %}#}

{#            {% if referencedEntity.selfContentType is defined %}#}
{#				<i class="{{ ico(referencedEntity) }} visible-sm-inline-block visible-xs-inline-block"></i>#}
{#            {% else %}#}
{#                <i data-set-type-responsive class="visible-sm-inline-block visible-xs-inline-block"></i>#}
{#            {% endif %}#}

{#            <a href="#" data-plugin="editable" data-for="{{ form.title.vars.id }}" data-type="text" data-enablefocus="true" data-pk="1" data-original-title="{{ form.title.vars.value|default(text) }}" data-set-title>{{ form.title.vars.value|default(text) }}</a>#}
{#            {{ form_widget(form.title, {attr:{'data-required':'required'}}) }}#}
{#			<span data-set-related-count>#}
{#				{% if referencedEntity.relatedContents is defined and referencedEntity.relatedContents|length > 0 %}#}
{#					({{ referencedEntity.relatedContents.count}} {{'cs_core.label.relations'|transchoice(referencedEntity.relatedContents|length) }} )#}
{#                    {% if referencedEntity.defaultSubsite != current_subsite() %}#}
{#						<span class="subsite">{{ referencedEntity.defaultSubsite.name }}</span>#}
{#                    {% endif %}#}
{#				{% endif %}#}
{#			</span>#}
{#        </td>#}

{#        {% if referencedEntity.state is defined %}#}
{#			<td class="hidden-xs hidden-sm">#}
{#				<span class="status {{ referencedEntity.state.name|default('') }} text-center">#}
{#					{{ referencedEntity.state is defined ? ("workflow.states." ~ referencedEntity.state.name )|trans : "-" }}#}
{#				</span>#}
{#			</td>#}
{#        {% else %}#}
{#			<td class="hidden-xs hidden-sm" data-set-state></td>#}
{#        {% endif %}#}

{#		{% set publishAt = has_property(referencedEntity,'publishedAt')  ? referencedEntity.publishedAt : '' %}#}

{#		{% if publishAt != '' %}#}
{#			<td class="hidden-md hidden-xs hidden-sm" data-set-publish-at>{{ time_diff(referencedEntity.publishedAt) }}</td>#}
{#		{% else %}#}
{#			<td class="hidden-md hidden-xs hidden-sm text-center" data-set-publish-at>-</td>#}
{#		{% endif %}#}

{#		<td class="text-center">#}
{#			<span class="opts">#}
{#				{% set bidirectional = related.bidirectional is defined ? related.bidirectional : '0' %}#}

{#                {% set bidirectional = related.bidirectional is defined ? related.bidirectional : '0' %}#}
{#                {% set disabledBidirectional = referencedEntity.selfContentType is defined and referencedEntity.selfContentType in unidirectional_content_type() ? 'disabled' : '' %}#}

{#                <a href="#" {{ disabledBidirectional }} data-action="bidirectional" data-is-bidirectional="{{ bidirectional ? 1 : 0 }}" title="{{ bidirectional ? 'related_content.elements.bidirectional-disabled'|trans : 'related_content.elements.bidirectional-active'|trans }}" class="btn btn-icon-only btn-circle default {{ bidirectional ? 'active' : '' }}">#}
{#                    <i class="fa fa-refresh"></i>#}
{#                </a>#}

{#                {{ form_widget(form.bidirectional,{attr:{'data-bidirectional':'', 'value': bidirectional > 0 ? 1 : 0 }}) }}#}


{#				{% if referencedEntity %}#}
{#					<a href="{{ path(referencedEntity.route, referencedEntity.routeParams) }}"#}
{#					   title="{{'cs_core.label.update'|trans|capitalize}}"#}
{#					   class="btn btn-icon-only btn-circle blue"#}
{#					   target="_blank"#}
{#					   {% if referencedEntity.defaultSubsite != current_subsite() %}disabled="disabled"{% endif %}#}
{#					>#}
{#					   <i class="fa fa-pencil"></i>#}
{#					</a>#}
{#				{% else %}#}
{#				<a href="#" title="{{'cs_core.label.update'|trans|capitalize}}" class="btn btn-icon-only btn-circle blue" data-edit-url="" target="_blank">#}
{#				   <i class="fa fa-pencil"></i>#}
{#				</a>#}
{#				{% endif %}#}

{#				{% if referencedEntity %}#}
{#					{% set previewUrl = generate_public_url(referencedEntity) %}#}
{#					<a href="{{ previewUrl|default("#") }}" title="{{'cs_core.label.preview'|trans|capitalize}}" class="btn btn-icon-only btn-circle blue" target="_blank" {% if previewUrl is null %}disabled="disabled" {% endif %}>#}
{#						<i class="fa fa-link"></i>#}
{#					</a>#}
{#                {% else %}#}
{#					<a href="#" title="{{'cs_core.label.preview'|trans|capitalize}}" class="btn btn-icon-only btn-circle blue" data-preview-url target="_blank">#}
{#						<i class="fa fa-link"></i>#}
{#					</a>#}
{#				{% endif %}#}

{#                <a href="#" title="{{ 'related_content.elements.remove'|trans }}" class="btn btn-icon-only btn-circle yellow-gold" data-action="remove-related"><i class="fa fa-minus"></i></a>#}
{#            </span>#}
{#        </td>#}
{#        <td class="hidden">{{ form_row(form.relatedUuid, {attr:{'data-set-related-uuid':''} }) }}</td>#}
{#        <td class="hidden">{{ form_row(form.relatedClass, {attr:{'data-set-related-class':''} }) }}</td>#}
{#        <td class="hidden" data-position="related-position">{{ form_row(form.position) }}</td>#}
{#    </tr>#}
{#{% endblock %}#}

{% block gender_widget %}
	{% spaceless %}
		{% if expanded %}
			<ul {{ block('widget_container_attributes') }}>
				{% for child in form %}
					<li>
						{{ form_widget(child) }}
						{{ form_label(child) }}
					</li>
				{% endfor %}
			</ul>
		{% else %}
			{# just let the choice widget render the select tag #}
			{{ block('choice_widget') }}
		{% endif %}
	{% endspaceless %}
{% endblock %}

{# @TODO Revisar per afegir datetime també#}
{% block date_widget -%}
	{% if widget == 'single_text' %}
		<div class="input-group date-picker input-daterange" data-date="{{ "now" | date('d/m/Y')}}" data-date-format="dd/mm/yyyy">
			{{- block('form_widget_simple') -}}
		</div>
	{% else -%}
		<div {{ block('widget_container_attributes') }}>
			{{- date_pattern|replace({
				'{{ year }}':  form_widget(form.year),
				'{{ month }}': form_widget(form.month),
				'{{ day }}':   form_widget(form.day),
			})|raw -}}
		</div>
	{%- endif %}
{%- endblock date_widget %}

{#@TODO canviar el input quan tinguem mes currencies.#}
{% block money_widget %}
    <div class="input-group input-small {{ special_class }}">
        {{ form_widget(form) }}
        <span class="input-group-addon">
            <i class="fa fa-euro"></i>
        </span>
    </div>
{% endblock %}

{% block file_upload_widget -%}

    <div class="cs_dropzone dropzone dz-clickable"
		data-url="{{ url(form.vars.targetUrl, form.vars.targetUrlParams) }}"
		data-upload-multiple="{{ form.vars.multiple|default(0) }}"
		data-method="{{ form.vars.method|default('post') }}"
		data-accepted-mime-types="{{ form.vars.mimeTypes }}"
		{% if form.vars.maxFiles %} data-max-files="{{ form.vars.maxFiles }}"{% endif %}>
		<div class="fallback">
			<input name="file" type="file" multiple accept="{{ form.vars.mimeTypes|default('*') }}"/>
		</div>

        <div class="dz-default dz-message">
			{{ 'cs_assets.messages.dropzone'|trans|raw }}
        </div>
    </div>
{% endblock %}

{% block text_spell_row -%}

	{% set attr = attr|merge({ "data-locale" : locale }) %}

	<div class="form-group spellit portlet-sortable-empty" data-action="spell_text">
		{{ block("form_label") }}
		<div class="input-group">
			<i style="display: none" class="fa fa-warning tooltips" data-original-title="{{ "common.label.spell_checker.error"|trans }}" data-container="body"></i>
			<i style="display: none" class="fa fa-check tooltips" data-original-title="{{ "common.label.spell_checker.success"|trans }}" data-container="body"></i>
			{{ block("form_widget") }}
			{{ block("form_errors") }}
			<span class="input-group-btn" title="{{ "common.label.spell_checker.title"|trans }}">
				<button class="btn default" type="button"><i class="fa fa-font"></i></button>
			</span>
		</div>
		{% if help %}<p class="help-block">{{ (translatable ? help|trans : help)|raw }}</p>{% endif %}
	</div>
{% endblock %}

{% block textarea_spell_row -%}

	{% set attr = attr|merge({"class": "form-control" ,"data-locale" : locale }) %}

	<div class="form-group spellit portlet-sortable-empty" data-action="spell_text">
		{{ block("form_label") }}
		<div class="input-group spellit_ta">
			<i style="display: none" class="fa fa-warning tooltips" data-original-title="{{ "common.label.spell_checker.error"|trans }}" data-container="body"></i>
			<i style="display: none" class="fa fa-check tooltips" data-original-title="{{ "common.label.spell_checker.success"|trans }}" data-container="body"></i>
			{{ block("textarea_widget") }}
			{{ block("form_errors") }}
			<span class="input-group-btn" title="{{ "common.label.spell_checker.title"|trans }}">
				<button class="btn default" type="button"><i class="fa fa-font"></i></button>
			</span>
		</div>
		{% if help %}<p class="help-block">{{ (translatable ? help|trans : help)|raw }}</p>{% endif %}
	</div>
{% endblock %}

{% block locales_row %}
	{% set _display  = locales|length == 1 and  hideIfOnlyOne ? "none" : "block" %}
	{% set _selected = form.vars.data.id|default(null) %}

	<div class="form-group" style="display: {{ _display }};">
		{{- form_label(form, label, { label_attr: label_attr }) -}}
		<select id="{{ form.vars.id }}"
				name="{{ form.vars.full_name }}"
				class="select2 select2-language form-control"
				data-image-path="/bundles/comitium5designer/global/img/flags/">

            {% if placeholder %}
                <option value="">{{ (placeholder)|trans }}</option>
            {% endif %}

			{% for locale in locales %}
				<option value="{{ locale.id }}" data-slug="{{ locale.code }}" {% if _selected == locale.id %}selected{% endif %}>
					{{ locale.name }}
				</option>
			{% endfor %}
		</select>
	</div>
{% endblock %}
