Commit bf08e0af authored by Compony's avatar Compony

Initial commit

parents
{#
/**
* @file
* Theme override for a 'form' element.
*
* Available variables
* - attributes: A list of HTML attributes for the wrapper element.
* - children: The child elements of the form.
*
* @see template_preprocess_form()
*/
#}
{{ attach_library('compony/form') }}
{%
set classes = [
'form',
'form--' ~ element['#form_id']|clean_class
]
%}
{% block before %}{% endblock %}
<form{{ attributes.addClass(classes) }}>
{% block content %}
{{ children }}
{% endblock %}
</form>
{% block after %}{% endblock %}
<?php
/**
* Implements hook_theme_suggestions_HOOK() for form suggestion.
*/
function compony_theme_suggestions_form_alter(array &$suggestions, array $variables) {
$suggestions[] = 'form__' . str_replace('-', '_', $variables['element']['#form_id']);
}
/*
* Implements template_preprocess_hook().
*/
function compony_preprocess_form(&$variables, $hook) {
// Create the possibility to use different preprocess function for
// different forms.
if (isset($variables['element']['#form_id'])) {
$form_id = str_replace("-", "_", $variables['element']['#form_id']);
$function = __FUNCTION__ . '__' . $form_id;
if (function_exists($function)) {
$function($variables, $hook);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment