35
Какие-то хуки по перезаписи для форм в Drupal
<?php
//Хук для вывода twig форм
function creozavr_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
if ($hook === 'form' && !empty($variables['element']['#id'])) {
$suggestions[] = 'form__' . str_replace('-', '_', $variables['element']['#id']);
}
}
// Какие-то хуки по темизации текстовых полей
function creozavr_theme_suggestions_input_alter(&$suggestions, array $variables) {
$element = $variables['element'];
if ($element['#type'] == 'textfield' && strpos($element['#id'], 'edit-subject-') === 0) {
$suggestions[] = 'input__textfield__subject';
}
}
function creozavr_theme_suggestions_textarea_alter(&$suggestions, array $variables) {
$element = $variables['element'];
if (strpos($element['#id'], 'edit-comment-body-') === 0) {
$suggestions[] = 'textarea__comment_body';
}
}
// Хук отсюда - https://drupal.ru/node/132248
function creozavr_theme_suggestions_form_element_alter(array &$suggestions, array $variables, $hook) {
if (isset($variables['element']['#user-login-form'])) {
$suggestions[] = 'form_element__' . explode("[", $variables['element']['#user-login-form'])[0];
}
}
$form['user_login_form']['#attributes']['data-twig-suggestion'] = 'userloginform'; //
$form['user_login_form']['#attributes']['data-twig-suggestion'] = 'userloginform';
function creozavr_theme_suggestions_input_alter (&$suggestions, array $variables){
$element = $variables['element'];
if (isset($element['#attributes']['data-twig-suggestion'])) {
if ($element['#attributes']['data-twig-suggestion'] == 'userloginform') {
$suggestions[] = 'input__user_login_form';
}
}
}
/**
* Implements hook_theme_suggestions_input_alter().
*/
//function creozavr_theme_suggestions_input_alter(&$suggestions, array $variables) {
//
//$element = $variables['element'];
//
//if (isset($element['#attributes']['data-twig-suggestion'])) {
//
// if ($element['#attributes']['data-twig-suggestion'] == 'userloginform') {
//
// $suggestions[] = 'input__user_login_form';
//
// }
//
//}
//
//}