templates/website/user/profile/user-custom-form.html.twig line 1

Open in your IDE?
  1. {% from 'utils.html.twig' import ico %}
  2. {% for field in fields %}
  3.     <div class="cp {{ field.type == enum('UserCustomFieldEnum::FIELD_LONGTEXT') ? 'cp-4-2' : 'cp-4' }} cp-custom">
  4.         <label for="{{ field.id }}">
  5.             {{ field.title }}
  6.                {% if field.required == enum('UserCustomFieldEnum::YES') %} <em>*</em>{% endif %}
  7.         </label>
  8.         {# TEXT #}
  9.         {% if field.type == enum('UserCustomFieldEnum::FIELD_TEXT') %}
  10.             <input 
  11.                 id="{{ field.id }}"
  12.                 type="text"
  13.                 name="field[{{ field.id }}]"
  14.                 cod="{{ field.type }}"
  15.                 value="{{ field.value }}"
  16.                 custom-field
  17.                 {% if field.required == enum('UserCustomFieldEnum::YES') %} 
  18.                     required="required"
  19.                 {% endif %}
  20.                 {% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %} 
  21.                     disabled="disabled"
  22.                 {% endif %}
  23.                 {% if field.size > 0 %}
  24.                     maxlength="{{ field.size }}"
  25.                 {% endif %}>
  26.         {# INT #}
  27.         {% elseif field.type == enum('UserCustomFieldEnum::FIELD_INT') %}
  28.             <input 
  29.                 id="{{ field.id }}"
  30.                 type="number"
  31.                 name="field[{{ field.id }}]"
  32.                 cod="{{ field.type }}"
  33.                 value="{{ field.value }}"
  34.                 custom-field
  35.                 {% if field.required == enum('UserCustomFieldEnum::YES') %} 
  36.                     required="required"
  37.                 {% endif %}
  38.                 {% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %} 
  39.                     disabled="disabled" 
  40.                 {% endif %}>
  41.         {# DOUBLE #}
  42.         {% elseif field.type == enum('UserCustomFieldEnum::FIELD_DOUBLE') %}
  43.             <input 
  44.                 id="{{ field.id }}"
  45.                 type="text"
  46.                 name="field[{{ field.id }}]"
  47.                 class="float-inp" 
  48.                 cod="{{ field.type }}"
  49.                 value="{{ field.value }}"
  50.                 custom-field
  51.                 {% if field.required == enum('UserCustomFieldEnum::YES') %} 
  52.                     required="required"
  53.                 {% endif %}
  54.                 {% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %} 
  55.                     disabled="disabled" 
  56.                 {% endif %}>
  57.         {# LONGTEXT #}
  58.         {% elseif field.type == enum('UserCustomFieldEnum::FIELD_LONGTEXT') %}
  59.             {% set edit = not (field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty) %}
  60.             {% set tag = edit? 'textarea':'div' %}
  61.             <{{ tag }}
  62.                 id="{{ field.id }}"
  63.                 name="field[{{ field.id }}]"
  64.                 cod="{{ field.type }}"
  65.                 custom-field
  66.                 {% if field.required == enum('UserCustomFieldEnum::YES') %} 
  67.                     required="required"
  68.                 {% endif %}
  69.                 {% if edit %} 
  70.                     class="js--editor"
  71.                 {% else %}
  72.                     disabled="disabled"
  73.                     class="fr-view text-noedit"
  74.                 {% endif %}
  75.                 >{{ field.value|raw }}
  76.             </{{ tag }}>
  77.         {# OPTION SELECT #}
  78.         {% elseif field.type == enum('UserCustomFieldEnum::FIELD_OPTION_SELECT') %}
  79.             <select 
  80.                 id="{{ field.id }}"
  81.                 type="text"
  82.                 name="field[{{ field.id }}]"
  83.                 cod="{{ field.type }}"
  84.                 custom-field
  85.                 {% if field.required == enum('UserCustomFieldEnum::YES') %} 
  86.                     required="required"
  87.                 {% endif %}
  88.                 {% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %} 
  89.                     disabled="disabled" 
  90.                 {% endif %}>
  91.                 <option value="">Selecione...</option>
  92.                 {% for option in field.optionsObj %}
  93.                     <option {% if field.value == option.value %} selected="selected=" {% endif %} value="{{ option.value }}">
  94.                         {{ option.text }}
  95.                     </option>
  96.                 {% endfor %}
  97.             </select>
  98.         {# RADIOS #}
  99.         {% elseif field.type == enum('UserCustomFieldEnum::FIELD_OPTION_RADIO') %}
  100.             {% set fieldDisabled = (field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty) %}
  101.             <div id="{{ field.id }}" 
  102.                 custom-field 
  103.                 cod="{{ field.type }}">
  104.                 <div class="wrap-boxes">
  105.                     {% for k, option in field.optionsObj %}
  106.                         <label for="radio_{{ k }}_{{ field.id }}" class="cp-radio{{ fieldDisabled?' disabled' }}">
  107.                             <input 
  108.                                 id="radio_{{ k }}_{{ field.id }}"
  109.                                 type="radio"
  110.                                 name="field[{{ field.id }}]"
  111.                                 class="float-inp custom-input-group"
  112.                                 value="{{ option.value }}"
  113.                                 {% if field.value == option.value %} 
  114.                                     checked="checked"
  115.                                 {% endif %}
  116.                                 {% if field.required == enum('UserCustomFieldEnum::YES') %} 
  117.                                     required="required"
  118.                                 {% endif %}
  119.                                 {% if fieldDisabled %} 
  120.                                     disabled="disabled"
  121.                                 {% endif %}>
  122.                             <span class="check material-icons">radio_button_unchecked</span>
  123.                             <span class="check material-icons">radio_button_checked</span>
  124.                             <span class="txt">{{ option.text }}</span>
  125.                         </label>
  126.                     {% endfor %}
  127.                 </div>
  128.             </div>
  129.         {# CHECKBOXES #}
  130.         {% elseif field.type == enum('UserCustomFieldEnum::FIELD_MULTIPLE') %}
  131.             {% set fieldDisabled = (field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty) %}
  132.             <div id="{{ field.id }}" 
  133.                 custom-field 
  134.                 cod="{{ field.type }}">
  135.                 <div class="wrap-boxes">
  136.                     {% for k, option in field.optionsObj %}
  137.                         <label for="checkbox_{{ k }}_{{ field.id }}" class="cp-radio{{ fieldDisabled?' disabled' }}">
  138.                             <input
  139.                                 id="checkbox_{{ k }}_{{ field.id }}"
  140.                                 type="checkbox"
  141.                                 name="field[{{ field.id }}][]"
  142.                                 class="float-inp custom-input-group"
  143.                                 value="{{ option.value }}"
  144.                                 required
  145.                                 {% if option.checked %}
  146.                                     checked="checked"
  147.                                 {% endif %}
  148.                                 {% if field.required == enum('UserCustomFieldEnum::YES') %} 
  149.                                     required="required"
  150.                                 {% endif %}
  151.                                 {% if fieldDisabled %}
  152.                                     disabled="disabled" 
  153.                                 {% endif %}>
  154.                             <span class="check material-icons">check_box_outline_blank</span>
  155.                             <span class="check material-icons">check_box</span>
  156.                             <span class="txt">{{ option.text }}</span>
  157.                         </label>
  158.                     {% endfor %}
  159.                 </div>
  160.             </div>
  161.         {# MASK #}
  162.         {% elseif field.type == enum('UserCustomFieldEnum::FIELD_MASK') %}
  163.             <input 
  164.                 id="{{ field.id }}"
  165.                 type="text"
  166.                 name="field[{{ field.id }}]"
  167.                 class="mask-inp" 
  168.                 cod="{{ field.type }}"
  169.                 value="{{ field.value }}"
  170.                 data-mask="{{ field.options }}"
  171.                 custom-field
  172.                 {% if field.required == enum('UserCustomFieldEnum::YES') %} 
  173.                     required="required"
  174.                 {% endif %}
  175.                 {% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %} 
  176.                     disabled="disabled" 
  177.                 {% endif %}>
  178.         {# FILE #}
  179.         {% elseif field.type == enum('UserCustomFieldEnum::FIELD_FILE') %}
  180.             {# Cheio e Não Editável #}
  181.             {% if (field.value is not empty) and (field.value.path is defined) and (field.allowEdit == enum('UserCustomFieldEnum::NO')) %}
  182.                 <div 
  183.                     custom-field
  184.                     class="input-file"
  185.                     size="{{ field.value.size }}"
  186.                     type-content="{{ field.value.type }}"
  187.                     name-content="{{ field.value.name }}"
  188.                     path="{{ field.value.path }}"
  189.                     extension="{{ field.value.extension }}"
  190.                 >
  191.                     <p class="file-label filename">{{ field.value.name }}</p>
  192.                 </div>
  193.             {% endif %}
  194.             {# Vazio ou Editável #}
  195.             {% if (field.value is empty) or (field.allowEdit == enum('UserCustomFieldEnum::YES')) %}
  196.                 <div class="dropfile js--dropfile input-file"
  197.                     data-status="{{ (field.value is empty)? 'empty':'full' }}"
  198.                     data-btn-delete="{{ (field.value is not empty)? "#btn-delete-#{field.id}" }}">
  199.                     <div class="drop-area js--dropfile-area">
  200.                         {{ ico('upload') }}
  201.                         <div class="drop-label">
  202.                             <p class="filename show-empty">{{ getLanguage('drop_file', 'profile') }}</p>
  203.                             <p class="filename show-wait">{{ getLanguage('wait', 'util') }}&hellip;</p>
  204.                             <p class="filename show-full js--dropfile-file-label">{{ (field.value is not empty)? field.value.name }}</p>
  205.                         </div>
  206.                     </div>
  207.                     <input
  208.                         custom-field
  209.                         class="js--dropfile-input"
  210.                         id="{{ field.id }}"
  211.                         type="file"
  212.                         name="files[{{ field.id }}]"
  213.                         data-delete-url="{{ path('userDeleteCustomFile', { id: user.id, fieldId: field.id }) }}"
  214.                         cod="{{ field.type }}"
  215.                         data-status="{{ (field.value is empty) ? 'empty' : 'full' }}"
  216.                         {% if (field.value is not empty) %}
  217.                             size="{{ field.value.size }}"
  218.                             type-content="{{ field.value.type }}"
  219.                             name-content="{{ field.value.name }}"
  220.                             path="{{ field.value.path|default('') }}"
  221.                             extension="{{ field.value.extension|default('') }}"
  222.                         {% endif %}
  223.                         {% if field.value is not empty %} 
  224.                             disabled="disabled" 
  225.                         {% endif %}
  226.                         {% if field.required == enum('UserCustomFieldEnum::YES') %}
  227.                             required="required" 
  228.                         {% endif %}>
  229.                 </div>
  230.             {% endif %}
  231.             {# ACTIONS #}
  232.             {# Cheio #}
  233.             {% if field.value is not empty %}
  234.                 <nav class="actions">
  235.                     <a href="{{ path('userDownloadCustom', { id: user.id, fieldId: field.id }) }}" class="btn-ed" download>{{ ico('download') }}DOWNLOAD</a>
  236.                     {# Cheio e Editável #}
  237.                     {% if field.allowEdit == enum('UserCustomFieldEnum::YES') %}
  238.                         <button id="btn-delete-{{ field.id }}" type="button" class="js--dropfile-btn-delete btn-ed">
  239.                             {{ ico('delete') }}{{ getLanguage('delete', 'profile') }}
  240.                         </button>
  241.                     {% endif %}
  242.                 </nav>
  243.             {% endif %}
  244.         {% endif %}
  245.     </div>
  246. {% endfor %}