diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeField.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeField.php index 34ff98e..36037e5 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeField.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeField.php @@ -49,7 +49,7 @@ public function defaultValuesForm(array &$form, array &$form_state) { * {@inheritdoc} */ public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state) { - return $form_state['values']['default_value_input']; + return array(array($form_state['values']['default_value_input']['default_date'])); } /** @@ -62,13 +62,11 @@ public function getDefaultValue() { $value = ''; $date = ''; if ($default_value['default_date'] == static::DEFAULT_VALUE_NOW) { - // A default value should be in the format and timezone used for date // storage. $date = new DrupalDateTime('now', DATETIME_STORAGE_TIMEZONE); $storage_format = $this->getFieldDefinition()->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE ? DATETIME_DATE_STORAGE_FORMAT: DATETIME_DATETIME_STORAGE_FORMAT; $value = $date->format($storage_format); - } // We only provide a default value for the first item, as do all fields. // Otherwise, there is no way to clear out unwanted values on multiple value diff --git a/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php b/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php index a5b43ee..56981b7 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php +++ b/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php @@ -291,22 +291,15 @@ function testDatelistWidget() { * Test default value functionality. */ function testDefaultValue() { - //Create a test content type. + // Create a test content type. $this->drupalCreateContentType(array('type' => 'date_content')); - $this->field = entity_create('field_entity', array( - 'name' => drupal_strtolower($this->randomName()), - 'entity_type' => 'node', - 'type' => 'datetime', - 'settings' => array('datetime_type' => 'date'), - )); - $this->field->save(); - $this->instance = entity_create('field_instance', array( + $instance = entity_create('field_instance', array( 'field_name' => $this->field->name, 'entity_type' => 'node', 'bundle' => 'date_content', )); - $this->instance->save(); + $instance->save(); // Set now as default_value. $instance_edit = array(