Loading core/lib/Drupal/Core/Render/Element/Table.php +1 −1 Changes for core/lib/Drupal/Core/Render/Element/Table.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ public static function processTable(&$element, FormStateInterface $form_state, & } } if (isset($title) && $title !== '') { $title = t('Update !title', array('!title' => $title)); $title = t('Update @title', array('@title' => $title)); } } Loading core/modules/system/src/Tests/Theme/TableTest.php +12 −1 Changes for core/modules/system/src/Tests/Theme/TableTest.php: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ class TableTest extends KernelTestBase { * * @var array */ public static $modules = array('system'); public static $modules = ['system', 'form_test']; /** * {@inheritdoc} Loading Loading @@ -308,4 +308,15 @@ public function testThemeTableRowRenderArray() { $this->assertRaw('<tbody><tr><td>1-one</td><td>1-two</td><td>1-three</td></tr>', 'Table row 1 found.'); $this->assertRaw('<tr><td>2-one</td><td>2-two</td><td><b>2-three</b></td></tr></tbody>', 'Table row 2 found.'); } /** * Tests that the select/checkbox label is being generated and escaped. */ public function testThemeTableTitle() { $form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestTableForm'); $this->render($form); $this->assertEscaped('Update <em>kitten</em>'); $this->assertRaw('Update my favourite fruit is <strong>bananas</strong>'); } } core/modules/system/tests/modules/form_test/src/Form/FormTestTableForm.php 0 → 100644 +52 −0 Changes for core/modules/system/tests/modules/form_test/src/Form/FormTestTableForm.php: 52 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\form_test\Form\FormTestTableForm. */ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormStateInterface; class FormTestTableForm extends FormTestTableSelectFormBase { /** * {@inheritdoc} */ public function getFormId() { return '_form_test_table_form'; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form['table'] = [ '#type' => 'table', '#tableselect' => TRUE, '#empty' => $this->t('Empty text.'), ]; $form['table']['row'] = [ 'data' => [ '#title' => '<em>kitten</em>', '#markup' => '<p>some text</p>', ], ]; $form['table']['another_row'] = [ 'data' => [ '#title' => $this->t('my favourite fruit is <strong>@fruit</strong>', ['@fruit' => 'bananas']), '#markup' => '<p>some more text</p>', ], ]; return $form; } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { } } Loading
core/lib/Drupal/Core/Render/Element/Table.php +1 −1 Changes for core/lib/Drupal/Core/Render/Element/Table.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ public static function processTable(&$element, FormStateInterface $form_state, & } } if (isset($title) && $title !== '') { $title = t('Update !title', array('!title' => $title)); $title = t('Update @title', array('@title' => $title)); } } Loading
core/modules/system/src/Tests/Theme/TableTest.php +12 −1 Changes for core/modules/system/src/Tests/Theme/TableTest.php: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ class TableTest extends KernelTestBase { * * @var array */ public static $modules = array('system'); public static $modules = ['system', 'form_test']; /** * {@inheritdoc} Loading Loading @@ -308,4 +308,15 @@ public function testThemeTableRowRenderArray() { $this->assertRaw('<tbody><tr><td>1-one</td><td>1-two</td><td>1-three</td></tr>', 'Table row 1 found.'); $this->assertRaw('<tr><td>2-one</td><td>2-two</td><td><b>2-three</b></td></tr></tbody>', 'Table row 2 found.'); } /** * Tests that the select/checkbox label is being generated and escaped. */ public function testThemeTableTitle() { $form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestTableForm'); $this->render($form); $this->assertEscaped('Update <em>kitten</em>'); $this->assertRaw('Update my favourite fruit is <strong>bananas</strong>'); } }
core/modules/system/tests/modules/form_test/src/Form/FormTestTableForm.php 0 → 100644 +52 −0 Changes for core/modules/system/tests/modules/form_test/src/Form/FormTestTableForm.php: 52 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Contains \Drupal\form_test\Form\FormTestTableForm. */ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormStateInterface; class FormTestTableForm extends FormTestTableSelectFormBase { /** * {@inheritdoc} */ public function getFormId() { return '_form_test_table_form'; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form['table'] = [ '#type' => 'table', '#tableselect' => TRUE, '#empty' => $this->t('Empty text.'), ]; $form['table']['row'] = [ 'data' => [ '#title' => '<em>kitten</em>', '#markup' => '<p>some text</p>', ], ]; $form['table']['another_row'] = [ 'data' => [ '#title' => $this->t('my favourite fruit is <strong>@fruit</strong>', ['@fruit' => 'bananas']), '#markup' => '<p>some more text</p>', ], ]; return $form; } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { } }