Skip to content
Snippets Groups Projects
Commit abb19f57 authored by catch's avatar catch
Browse files

Issue #2774195 by lauriii, claudiu.cristea: Passing attributes to field...

Issue #2774195 by lauriii, claudiu.cristea: Passing attributes to field element label is not possible
parent ce4e04f0
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -511,8 +511,6 @@ function template_preprocess_form_element_label(&$variables) {
$variables['title'] = ['#markup' => $element['#title']];
}
$variables['attributes'] = array();
// Pass elements title_display to template.
$variables['title_display'] = $element['#title_display'];
......
<?php
namespace Drupal\Tests\system\Kernel\Form;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\CssSelector\CssSelectorConverter;
/**
* Tests for form_element_label theme hook.
*
* @group Form
*/
class FormElementLabelTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* Ensures that attributes can be placed for form element label.
*/
public function testAttributes() {
$render_array = [
'#type' => 'label',
'#attributes' => ['class' => ['kitten']],
'#title' => 'Kittens',
'#title_display' => 'above',
];
$css_selector_converter = new CssSelectorConverter();
$this->render($render_array);
$elements = $this->xpath($css_selector_converter->toXPath('.kitten'));
$this->assertCount(1, $elements);
}
}
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