Skip to content

Commit

Permalink
Fixed #15512
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Aug 10, 2024
1 parent 83a0cfb commit 8460b5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Fixed a bug where Link fields weren’t allowing category groups to be selected, if they didn’t have a URI format for the primary site.
- Fixed an error that occurred when installing Craft in PostgreSQL. ([#15504](https://github.com/craftcms/cms/issues/15504))
- Fixed a bug where Matrix fields weren’t retaining the sort order for disabled nested entries. ([#15505](https://github.com/craftcms/cms/issues/15505))
- Fixed a bug where Link fields weren’t displaying their input if they only had one type selected, and it wasn’t URL. ([#15512](https://github.com/craftcms/cms/issues/15512))

## 5.3.1 - 2024-08-07

Expand Down
8 changes: 7 additions & 1 deletion src/fields/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,14 @@ public function useFieldset(): bool
protected function inputHtml(mixed $value, ?ElementInterface $element, bool $inline): string
{
$linkTypes = $this->getLinkTypes();

/** @var LinkData|null $value */
$valueTypeId = $value?->type ?? UrlType::id();
if ($value) {
$valueTypeId = $value->type;
} else {
$valueTypeId = in_array(UrlType::id(), $this->types) ? UrlType::id() : reset($this->types);
}

$allowedTypeIds = in_array($valueTypeId, $this->types) ? $this->types : array_merge($this->types, [$valueTypeId]);
$allowedTypeIds = array_filter($allowedTypeIds, fn(string $typeId) => isset($linkTypes[$typeId]));
$id = $this->getInputId();
Expand Down

0 comments on commit 8460b5f

Please sign in to comment.