Commit 885ac827 authored by alexpott's avatar alexpott

Issue #2110777 by larowlan, herom: Fixed Cannot edit a date format after creating it.

parent 49ac6300
......@@ -197,7 +197,7 @@ public function validate(array $form, array &$form_state) {
// name, check to see if the provided pattern exists.
$pattern = trim($form_state['values']['date_format_pattern']);
foreach ($this->dateFormatStorage->loadMultiple() as $format) {
if ($format->getPattern() == $pattern) {
if ($format->getPattern() == $pattern && ($this->entity->isNew() || $format->id() != $this->entity->id())) {
form_set_error('date_format_pattern', t('This format already exists. Enter a unique format string.'));
continue;
}
......
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\system\Tests\System\DateTimeTest.
* Contains \Drupal\system\Tests\System\DateTimeTest.
*/
namespace Drupal\system\Tests\System;
......@@ -96,6 +96,13 @@ function testDateFormatConfiguration() {
$this->assertText($date_format_id, 'Custom date format appears in the date format list.');
$this->assertText(t('Delete'), 'Delete link for custom date format appears.');
// Edit the custom date format and re-save without editing the format.
$this->drupalGet('admin/config/regional/date-time');
$this->clickLink(t('Edit'));
$this->drupalPostForm(NULL, NULL, t('Save format'));
$this->assertUrl('admin/config/regional/date-time', array('absolute' => TRUE), 'Correct page redirection.');
$this->assertText(t('Custom date format updated.'), 'Custom date format successfully updated.');
// Edit custom date format.
$this->drupalGet('admin/config/regional/date-time');
$this->clickLink(t('Edit'));
......
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