Last active
February 7, 2017 15:13
-
-
Save optii/b73fa91dbecdf9ab6743789f31b3170b to your computer and use it in GitHub Desktop.
Semantic UI twig layout using mdehoog/Semantic-UI-Calendar for calendars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
twig: | |
debug: "%kernel.debug%" | |
strict_variables: "%kernel.debug%" | |
form_themes: | |
- 'form/semantic_layout.html.twig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% use 'form_div_layout.html.twig' %} | |
{% block form_start -%} | |
{% set attr = attr|merge({class: (attr.class|default('') ~ ' ui form')|trim}) %} | |
{{- parent() -}} | |
{%- endblock form_start %} | |
{# Widgets #} | |
{% block form_widget_simple -%} | |
{{- parent() -}} | |
{%- endblock form_widget_simple %} | |
{% block textarea_widget -%} | |
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} | |
{{- parent() -}} | |
{%- endblock textarea_widget %} | |
{% block button_widget -%} | |
{% set attr = attr|merge({class: (attr.class|default('') ~ ' ui button')|trim}) %} | |
{{- parent() -}} | |
{%- endblock %} | |
{% block money_widget -%} | |
{{- block('form_widget_simple') -}} | |
{%- endblock money_widget %} | |
{% block percent_widget -%} | |
{{- block('form_widget_simple') -}} | |
{%- endblock percent_widget %} | |
{% block datetime_widget -%} | |
{% if value.date is defined %} | |
{% set value = value.date.day ~ '/' ~ value.date.month ~ '/' ~ value.date.year ~ ' ' ~ value.time.hour ~ ':' ~ value.time.minute %} | |
{% endif %} | |
<div class="ui calendar"> | |
<div class="ui input left icon"> | |
<i class="calendar icon"></i> | |
{{- block('form_widget_simple') -}} | |
</div> | |
</div> | |
{%- endblock datetime_widget %} | |
{% block date_widget -%} | |
{% if value.date is defined %} | |
{% set value = value.date.day ~ '/' ~ value.date.month ~ '/' ~ value.date.year %} | |
{% endif %} | |
<div class="ui calendar"> | |
<div class="ui input left icon"> | |
<i class="calendar icon"></i> | |
{{- block('form_widget_simple') -}} | |
</div> | |
</div> | |
{%- endblock date_widget %} | |
{% block time_widget -%} | |
{{- block('form_widget_simple') -}} | |
{%- endblock time_widget %} | |
{% block dateinterval_widget %} | |
{{- block('form_widget_simple') -}} | |
{% endblock dateinterval_widget %} | |
{% block checkbox_widget -%} | |
<div class="ui toggle checkbox"> | |
{% set attr = attr|merge({class: (attr.class|default(''))|trim}) %} | |
{{- form_label(form, null, { widget: parent() }) -}} | |
</div> | |
{%- endblock checkbox_widget %} | |
{% block radio_widget -%} | |
<div class="ui radio checkbox"> | |
{% set attr = attr|merge({class: (attr.class|default('') ~ ' hidden')|trim}) %} | |
{{- form_label(form, null, { widget: parent() }) -}} | |
</div> | |
{%- endblock radio_widget %} | |
{# Labels #} | |
{% block form_label -%} | |
{{- parent() -}} | |
{%- endblock form_label %} | |
{% block choice_label -%} | |
{{- block('form_label') -}} | |
{% endblock %} | |
{% block checkbox_label -%} | |
{{- block('checkbox_radio_label') -}} | |
{%- endblock checkbox_label %} | |
{% block radio_label -%} | |
{{- block('checkbox_radio_label') -}} | |
{%- endblock radio_label %} | |
{% block checkbox_radio_label %} | |
{# Do not display the label if widget is not defined in order to prevent double label rendering #} | |
{% if widget is defined %} | |
{% if required %} | |
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} | |
{% endif %} | |
{% if label is not same as(false) and label is empty %} | |
{%- if label_format is not empty -%} | |
{% set label = label_format|replace({ | |
'%name%': name, | |
'%id%': id, | |
}) %} | |
{%- else -%} | |
{% set label = name|humanize %} | |
{%- endif -%} | |
{% endif %} | |
{{ widget|raw }} | |
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> | |
{{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}} | |
</label> | |
{% endif %} | |
{% endblock checkbox_radio_label %} | |
{# Rows #} | |
{% block form_row -%} | |
<div class="field{% if not valid %} error{% endif %}"> | |
{{- form_label(form) -}} | |
{{- form_widget(form) -}} | |
{{- form_errors(form) -}} | |
</div> | |
{%- endblock form_row %} | |
{% block button_row -%} | |
{{- form_widget(form) -}} | |
{%- endblock button_row %} | |
{% block choice_row -%} | |
{{- block('form_row') }} | |
{%- endblock choice_row %} | |
{% block date_row -%} | |
{{- block('form_row') }} | |
{%- endblock date_row %} | |
{% block time_row -%} | |
{{- block('form_row') }} | |
{%- endblock time_row %} | |
{% block datetime_row -%} | |
{{- block('form_row') }} | |
{%- endblock datetime_row %} | |
{% block checkbox_row -%} | |
<div class="field{% if not valid %} error{% endif %}"> | |
{{- form_widget(form) -}} | |
{{- form_errors(form) -}} | |
</div> | |
{%- endblock checkbox_row %} | |
{% block radio_row -%} | |
<div class="field{% if not valid %} error{% endif %}"> | |
{{- form_widget(form) -}} | |
{{- form_errors(form) -}} | |
</div> | |
{%- endblock radio_row %} | |
{%- block choice_widget_collapsed -%} | |
{%- if required and placeholder is none and not placeholder_in_choices and not multiple and (attr.size is not defined or attr.size <= 1) -%} | |
{% set required = false %} | |
{%- endif -%} | |
{% set attr = attr|merge({class: (attr.class|default('') ~ ' ui fluid dropdown')|trim}) %} | |
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}> | |
{%- if placeholder is not none -%} | |
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder != '' ? (translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain)) }}</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> | |
{%- endblock choice_widget_collapsed -%} | |
{# Errors #} | |
{% block form_errors -%} | |
{% if errors|length > 0 -%} | |
<div class="ui pointing red label"> | |
<i class="warning sign icon"></i> | |
{%- for error in errors -%} | |
{{ error.message }} | |
{%- endfor -%} | |
</div> | |
{%- endif %} | |
{%- endblock form_errors %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment