Commit abb19f57 authored by catch's avatar catch

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
......@@ -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);
}
}
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