deblan.tv/vendor/trinity/src/Trinity/Bundle/WidgetBundle/Resources/views/Form/fields.html.twig

157 lines
7.4 KiB
Twig
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% block widget_attributes %}
{% spaceless %}
id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
{% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title', 'data-help'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
{% endspaceless %}
{% endblock widget_attributes %}
{% block file_widget %}
{# {% set dir = attr.upload_dir is defined ? attr.upload_dir ~ '/' : '/' %} #}
{% if form.vars.data is not null %}
{% set filename = form.vars.data %}
{% elseif form.parent is defined and form.parent.vars.data is not null %}
{% set method = 'get' ~ name|capitalize ~ 'AsFile' %}
{% set filename = attribute(form.parent.vars.data, method, []) %}
{% else %}
{% set filename = null %}
{% endif %}
{% if filename %}
{% set is_image = filename.__toString()|replace({'.png': '', '.jpg': '', '.jpeg': '', '.gif': ''})|length < filename.__toString()|length %}
{% else %}
{% set is_image = false %}
{% endif %}
<div {% if attr['data-help'] is defined %}data-help="{{ attr['data-help'] }}"{% endif %} class="fileupload fileupload-new" data-provides="fileupload">
<span class="btn btn-file">
<span class="fileupload-new">{{ 'crud.form.file.select'|trans({}, 'TrinityAdminBundle') }}</span>
<span class="fileupload-exists">{{ 'crud.form.file.change'|trans({}, 'TrinityAdminBundle') }}</span>
<input type="{{ type }}" {{ block('widget_attributes') }} data-help-show="false" {% if value is not empty %}value="{{ value|raw }}" {% endif %}/>
</span>
&nbsp;<span class="fileupload-preview"></span>&nbsp;<a href="#" class="close fileupload-exists" data-dismiss="fileupload" style="float: none">×</a>
{% if filename is not empty and form.vars.valid %}
<div class="file-preview">
<label>
{{ 'form.field.file.delete'|trans({}, 'TrinityWidgetBundle') }}
<input type="checkbox" class="delete_checkbox" name="{{ full_name|replace({(name): 'delete_' ~ name}) }}" />
</label>
{% if not is_image %}
<a target="_blank" href="{{ asset(filename) }}" title="{{ 'form.field.file.open'|trans({}, 'TrinityWidgetBundle') }}"><i class="icon-eye-open"></i></a>
{% endif %}
</div>
{% endif %}
</div>
{% if is_image %}
<a target="_blank" class="file-preview-lightbox-img" href="{{ asset(filename) }}" title="{{ 'form.field.file.open'|trans({}, 'TrinityWidgetBundle') }}">
<img src="{{ asset(filename) }}" class="file-preview-img" alt="" /><br />
</a>
{% endif %}
{% endblock file_widget %}
{% block simple_file_widget %}
<input type="{{ type }}" {{ block('widget_attributes') }} data-help-show="false" {% if value is not empty %}value="{{ value|raw }}" {% endif %}/>
{{ 'form.field.file.delete'|trans({}, 'TrinityWidgetBundle') }}
<input type="checkbox" class="delete_checkbox" name="{{ full_name|replace({(name): 'delete_' ~ name}) }}" />
{% endblock simple_file_widget %}
{% block editorial_blocks_container_block_widget %}
{% set type = type|default('hidden') %}
{% macro prototype(editorial_block) %}
<tr data-id="{{ editorial_block.id }}">
<td width="485">{{ editorial_block.name }}</td>
<td width="15">
<i title="{{ 'cms.node.action.remove'|trans({}, 'TrinityContentManagerBundle') }}" data-id="{{ editorial_block.id }}" class="editorial_block_remove icon-remove"></i>
</td>
</tr>
{% endmacro %}
{% macro parent_prototype() %}
<tr data-id="USE_PARENT">
<td width="485">
{{ 'form.field.editorial_blocks_container.use_parent'|trans({}, 'TrinityWidgetBundle') }}
</td>
<td width="15">
<i title="{{ 'cms.node.action.remove'|trans({}, 'TrinityContentManagerBundle') }}" data-id="USE_PARENT" class="editorial_block_remove icon-remove"></i>
</td>
</tr>
{% endmacro %}
{% import _self as macros %}
<div class="editorial_block_table" {% if attr['data-help'] is defined %}data-help="{{ attr['data-help'] }}"{% endif %} >
{% for child in form %}
{{ form_widget(child) }}
{% endfor %}
<table class="table table-bordered table-hover">
<thead>
<tr>
<th colspan="2">{{ 'form.field.editorial_blocks_container.items'|trans({}, 'TrinityWidgetBundle') }}</th>
</tr>
</thead>
<tfoot>
{% if editorial_blocks|length == 0 %}
<tr>
<td colspan="2">
<p>{{ 'form.field.editorial_blocks_container.no_blocks'|trans({}, 'TrinityWidgetBundle') }}</p>
</td>
</tr>
{% else %}
<tr>
<td colspan="2">
<p>
<select class="editorial_block_select">
{% for editorial_block in editorial_blocks %}
<option data-prototype="{% spaceless %}{{ macros.prototype(editorial_block)|e }}{% endspaceless %}" value="{{ editorial_block.id }}">{{ editorial_block.name }}</option>
{% endfor %}
<option data-prototype="{% spaceless %}{{ macros.parent_prototype()|e }}{% endspaceless %}" value="USE_PARENT" >{{ 'form.field.editorial_blocks_container.use_parent'|trans({}, 'TrinityWidgetBundle') }}</option>
</select>
&nbsp;
<input type="button" class="btn editorial_block_add" value="{{ 'form.field.editorial_blocks_container.add'|trans({}, 'TrinityWidgetBundle') }}" />
</p>
</td>
</tr>
{% endif %}
</tfoot>
<tbody>
<tr class="editorial_block_no_blocks" style="display: none">
<td>
<p>{{ 'form.field.editorial_blocks_container.no_associated_blocks'|trans({}, 'TrinityWidgetBundle') }}</p>
</td>
</tr>
{% for editorial_block in associated_editorial_blocks %}
{% if editorial_block == 'USE_PARENT' %}
{{ macros.parent_prototype() }}
{% else %}
{{ macros.prototype(editorial_block) }}
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
{% block form_errors %}
{% spaceless %}
{% if errors is defined and errors|length > 0 %}
<ul class="error_list">
{% for error in errors %}
<li>{{
error.messagePluralization is null
? error.messageTemplate|trans(error.messageParameters, 'validators')
: error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators')
}}</li>
{% endfor %}
</ul>
{% endif %}
{% endspaceless %}
{% endblock form_errors %}