Skip to content
Snippets Groups Projects
Commit ad5980c7 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2152211 by joelpittet, IshaDakota, rteijeiro, steveoliver, hussainweb,...

Issue #2152211 by joelpittet, IshaDakota, rteijeiro, steveoliver, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_form() to Twig.
parent f258db4d
No related branches found
No related tags found
No related merge requests found
...@@ -2680,16 +2680,16 @@ function form_pre_render_color($element) { ...@@ -2680,16 +2680,16 @@ function form_pre_render_color($element) {
} }
/** /**
* Returns HTML for a form. * Prepares variables for form templates.
*
* Default template: form.html.twig.
* *
* @param $variables * @param $variables
* An associative array containing: * An associative array containing:
* - element: An associative array containing the properties of the element. * - element: An associative array containing the properties of the element.
* Properties used: #action, #method, #attributes, #children * Properties used: #action, #method, #attributes, #children
*
* @ingroup themeable
*/ */
function theme_form($variables) { function template_preprocess_form(&$variables) {
$element = $variables['element']; $element = $variables['element'];
if (isset($element['#action'])) { if (isset($element['#action'])) {
$element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']); $element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']);
...@@ -2698,8 +2698,8 @@ function theme_form($variables) { ...@@ -2698,8 +2698,8 @@ function theme_form($variables) {
if (empty($element['#attributes']['accept-charset'])) { if (empty($element['#attributes']['accept-charset'])) {
$element['#attributes']['accept-charset'] = "UTF-8"; $element['#attributes']['accept-charset'] = "UTF-8";
} }
// Anonymous DIV to satisfy XHTML compliance. $variables['attributes'] = $element['#attributes'];
return '<form' . new Attribute($element['#attributes']) . '><div>' . $element['#children'] . '</div></form>'; $variables['children'] = $element['#children'];
} }
/** /**
......
...@@ -2608,6 +2608,7 @@ function drupal_common_theme() { ...@@ -2608,6 +2608,7 @@ function drupal_common_theme() {
), ),
'form' => array( 'form' => array(
'render element' => 'element', 'render element' => 'element',
'template' => 'form',
), ),
'textarea' => array( 'textarea' => array(
'render element' => 'element', 'render element' => 'element',
......
{#
/**
* @file
* Default theme implementation 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()
*
* @ingroup themeable
*/
#}
<form{{ attributes }}><div>{{ children }}</div></form>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment