Skip to content

Commit

Permalink
fix: resource loading when rendering the field
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Mar 13, 2022
1 parent 643220b commit 1f632d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"authors": [{
"name": "Jeremy Shipman",
"email": "[email protected]"
}],
"autoload": {
"psr-4": {
"SilverShop\\HasOneField\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
"dev-main": "3.x-dev"
},
"expose": [
"client"
Expand Down
14 changes: 10 additions & 4 deletions src/HasOneButtonField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 1f632d1

Please sign in to comment.