From b7dc107be115a16739634c72c02826d18f46b668 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 13 Sep 2022 06:04:13 -0700 Subject: [PATCH 1/2] Update comments --- src/fields/Date.php | 2 +- src/fields/Number.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fields/Date.php b/src/fields/Date.php index 8d180537ea8..bc57a3763c4 100644 --- a/src/fields/Date.php +++ b/src/fields/Date.php @@ -250,7 +250,7 @@ protected function inputHtml($value, ElementInterface $element = null): string $timezone = $this->showTimeZone && $value ? $value->getTimezone()->getName() : Craft::$app->getTimeZone(); if ($value === null) { - // Override the initial value being set to null by _includes/forms/field + // Override the initial value being set to null by CustomField::inputHtml() $initialValue = []; if ($this->showDate) { $initialValue['date'] = ''; diff --git a/src/fields/Number.php b/src/fields/Number.php index 6eb604348a8..7a3d0770337 100644 --- a/src/fields/Number.php +++ b/src/fields/Number.php @@ -281,7 +281,7 @@ protected function inputHtml($value, ElementInterface $element = null): string } } } else { - // Override the initial value being set to null by _includes/forms/field + // Override the initial value being set to null by CustomField::inputHtml() $view->setInitialDeltaValue($this->handle, [ 'locale' => Craft::$app->getFormattingLocale()->id, 'value' => '', From 836dd5f2228a977b597580163ec3d7ed8a7aa350 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 13 Sep 2022 06:09:53 -0700 Subject: [PATCH 2/2] Fixed #11908 --- CHANGELOG.md | 1 + src/fields/Url.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d1e7d38d09..80e83390aea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Fixed a bug where it was possible to save an asset with a focal point outside its cropped area. ([#11875](https://github.com/craftcms/cms/issues/11875)) - Fixed a bug where the Assets index page wasn’t handling failed uploads properly. ([#11866](https://github.com/craftcms/cms/issues/11866)) - Fixed a UI bug where renaming a newly-created volume subfolder didn’t appear to have any effect. +- Fixed a bug where empty URL fields would be marked as changed, even when no change was made to them. ([#11908](https://github.com/craftcms/cms/issues/11908)) ## 3.7.53.1 - 2022-08-26 diff --git a/src/fields/Url.php b/src/fields/Url.php index 7d568ae7190..f1575671d66 100644 --- a/src/fields/Url.php +++ b/src/fields/Url.php @@ -241,13 +241,22 @@ protected function inputHtml($value, ElementInterface $element = null): string ], ]); + $view = Craft::$app->getView(); + + if ($value === null) { + // Override the initial value being set to null by CustomField::inputHtml() + $view->setInitialDeltaValue($this->handle, [ + 'type' => $valueType, + 'value' => '', + ]); + } + if (count($this->types) === 1) { return Html::hiddenInput("$this->handle[type]", $valueType) . $input; } - $view = Craft::$app->getView(); $namespacedId = $view->namespaceInputId($id); $js = << {