Skip to content
Snippets Groups Projects
Commit 885ac827 authored by Alex Pott's avatar Alex Pott
Browse files

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

parent 49ac6300
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment