Drupal 8. Темизация форм.

Главные вкладки

Аватар пользователя Lexins Lexins 4 мая 2016 в 10:22

Добрый день всем.
Изучаю друпал 8. В темплейтах есть файл form-element.html.twig, который влияет на вывод всех элементов формы на всех формах сайта абсолютно.
Уже сделал несколько форм как хотел. Но добрался до формы "user-form" (форма изменения пароля пользователя, когда он забывает пароль и пытается его изменить через почту), в ней сломалась верстка. Поэтому мне нужно изменить ширину бутстраповской сетки col-md-*, причем только для одной конкретной встроенной! формы.

Мой код form-element.html.twig:

        {%
  set classes = [
    'form-group',
    'js-form-item',
    'form-item',
    'js-form-type-' ~ type|clean_class,
    'form-item-' ~ name|clean_class,
    'js-form-item-' ~ name|clean_class,
    title_display not in ['after', 'before'] ? 'form-no-label',
    disabled == 'disabled' ? 'form-disabled',
    errors ? 'form-item--error',
  ]
%}
{%
  set description_classes = [
    'description',
    'col-md-10 col-md-offset-2',
    description_display == 'invisible' ? 'visually-hidden',
  ]
%}
<div{{ attributes.addClass(classes) }}>
  {% if label_display in ['before', 'invisible'] %}
    {{ label }}
  {% endif %}
  {% if prefix is not empty %}
    <span class="field-prefix">{{ prefix }}</span>
  {% endif %}
  {% if description_display == 'before' and description.content %}
    <div{{ description.attributes }}>
      {{ description.content }}
    </div>
  {% endif %}
  {{ children }}
  {% if suffix is not empty %}
    <span class="field-suffix">{{ suffix }}</span>
  {% endif %}
  {% if label_display == 'after' %}
    {{ label }}
  {% endif %}
  {% if errors %}
    <div class="form-item--error-message">
      {{ errors }}
    </div>
  {% endif %}
  {% if description_display in ['after', 'invisible'] and description.content %}
    <div{{ description.attributes.addClass(description_classes) }}>
      {{ description.content }}
    </div>
  {% endif %}
</div>

В документации drupal-а https://www.drupal.org/node/2354645 ни слова про формы и элементы. Кто-нибудь сталкивался с подобной задачей?

Комментарии

Аватар пользователя Lexins Lexins 4 мая 2016 в 10:25

Думал как выход взять form-id в файле form-element.html.twig и прописать проверку. Но этой переменной там не существует.

Аватар пользователя triamera977 triamera977 12 октября 2016 в 13:00

Здравствуйте. Есть форма(Drupal 8), называется zakazat_zvonok, как переименовать файл form-element.html.twig для темизации данной формы?