Skip to content

Commit

Permalink
FIX Add HasOneRelationFieldInterface to LinkField
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jan 31, 2024
1 parent 790c561 commit 09f637c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Form/LinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
use SilverStripe\LinkField\Models\Link;
use SilverStripe\LinkField\Form\Traits\AllowedLinkClassesTrait;
use SilverStripe\LinkField\Form\Traits\LinkFieldGetOwnerTrait;
use SilverStripe\Forms\HasOneRelationFieldInterface;

/**
* Allows CMS users to edit a Link object.
*/
class LinkField extends FormField
class LinkField extends FormField implements HasOneRelationFieldInterface
{
use AllowedLinkClassesTrait;
use LinkFieldGetOwnerTrait;
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Traits/LinkFieldGetOwnerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ private function getOwnerFields(): array
// Remove namespaces from inline editable blocks
// This will return an empty array for non-inline editable blocks (e.g. blocks in a gridfield)
$arr = ElementalAreaController::removeNamespacesFromFields([$relation => ''], $owner->ID);
if (array_key_exists(0, $arr)) {
$relation = array_keys($arr)[0];
if (!empty($arr)) {
$relation = array_key_first($arr);
}
}
return [
Expand Down

0 comments on commit 09f637c

Please sign in to comment.