From 9f6d914493639a7e3f56fbcbb15fcea278b19f32 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Thu, 6 Aug 2015 13:33:32 +0100 Subject: [PATCH] Issue #2528482 by googletorp, mpdonadio, TR: Fix notice in Date::processDate --- core/lib/Drupal/Core/Render/Element/Date.php | 2 ++ core/modules/system/src/Tests/Form/FormTest.php | 2 +- .../form_test/src/Form/FormTestDisabledElementsForm.php | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/lib/Drupal/Core/Render/Element/Date.php b/core/lib/Drupal/Core/Render/Element/Date.php index 233e1baff77..b0ef0f53a86 100644 --- a/core/lib/Drupal/Core/Render/Element/Date.php +++ b/core/lib/Drupal/Core/Render/Element/Date.php @@ -40,6 +40,8 @@ class Date extends FormElement { '#process' => [[$class, 'processDate']], '#pre_render' => [[$class, 'preRenderDate']], '#theme_wrappers' => ['form_element'], + '#attributes' => ['type' => 'date'], + '#date_date_format' => 'Y-m-d', ]; } diff --git a/core/modules/system/src/Tests/Form/FormTest.php b/core/modules/system/src/Tests/Form/FormTest.php index 5eab8aa377f..67508a28d69 100644 --- a/core/modules/system/src/Tests/Form/FormTest.php +++ b/core/modules/system/src/Tests/Form/FormTest.php @@ -533,7 +533,7 @@ class FormTest extends WebTestBase { // All the elements should be marked as disabled, including the ones below // the disabled container. $actual_count = count($disabled_elements); - $expected_count = 41; + $expected_count = 42; $this->assertEqual($actual_count, $expected_count, SafeMarkup::format('Found @actual elements with disabled property (expected @expected).', array( '@actual' => count($disabled_elements), '@expected' => $expected_count, diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php index 485d081472e..87df54a371a 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php @@ -142,6 +142,15 @@ class FormTestDisabledElementsForm extends FormBase { '#date_timezone' => 'Europe/Berlin', ); + $form['disabled_container']['disabled_container_date'] = array( + '#type' => 'date', + '#title' => 'date', + '#default_value' => '2001-01-13', + '#expected_value' => '2001-01-13', + '#test_hijack_value' => '2013-01-01', + '#date_timezone' => 'Europe/Berlin', + ); + // Try to hijack the email field with a valid email. $form['disabled_container']['disabled_container_email'] = array(