From 1f632d1b4c760cb99b8aba812dbded515e8791f4 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 14 Mar 2022 09:20:36 +1300 Subject: [PATCH] fix: resource loading when rendering the field --- composer.json | 6 +----- src/HasOneButtonField.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 8c706f3..497e0cb 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,6 @@ "require-dev": { "phpunit/phpunit": "^5.7" }, - "authors": [{ - "name": "Jeremy Shipman", - "email": "jeremy@burnbright.net" - }], "autoload": { "psr-4": { "SilverShop\\HasOneField\\": "src/" @@ -21,7 +17,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-main": "3.x-dev" }, "expose": [ "client" diff --git a/src/HasOneButtonField.php b/src/HasOneButtonField.php index 0b90e86..5054c65 100644 --- a/src/HasOneButtonField.php +++ b/src/HasOneButtonField.php @@ -53,16 +53,13 @@ public function __construct(DataObject $parent, $relationName, $fieldName = null $this->parent = $parent; $this->relation = $relationName; - Requirements::css("silvershop/silverstripe-hasonefield:client/dist/styles/bundle.css"); - Requirements::javascript("silvershop/silverstripe-hasonefield:client/dist/js/bundle.js"); - $config = GridFieldConfig::create() ->addComponent(new GridFieldHasOneButtonRow()) ->addComponent(new GridFieldSummaryField($relationName)) ->addComponent(new GridFieldDetailForm()) ->addComponent(new GridFieldHasOneUnlinkButton($parent, 'buttons-before-right')) ->addComponent(new GridFieldHasOneEditButton('buttons-before-right')); - + if ($useAutocompleter) { $config->addComponent(new HasOneAddExistingAutoCompleter('buttons-before-right')); } @@ -137,4 +134,13 @@ public function setRelation(string $relation) $this->relation = $relation; return $this; } + + + public function FieldHolder($properties = []) + { + Requirements::css("silvershop/silverstripe-hasonefield:client/dist/styles/bundle.css"); + Requirements::javascript("silvershop/silverstripe-hasonefield:client/dist/js/bundle.js"); + + return parent::FieldHolder($properties); + } }