Skip to content

Commit

Permalink
Merge pull request elliot-sawyer#17 from silverstripe-terraformers/fe…
Browse files Browse the repository at this point in the history
…ature/improved-configuration

NEW: New extension point for has one and many fields.
  • Loading branch information
gorriecoe authored May 20, 2020
2 parents 8c8a999 + 4c59c0f commit fdd3723
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/LinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,18 @@ public function getRecord()
*/
public function getHasOneField()
{
return HasOneButtonField::create(
$field = HasOneButtonField::create(
$this->parent,
$this->name,
null,
$this->title
)
->setForm($this->Form)
->addExtraClass('linkfield__button');

$this->extend('updateHasOneField', $field);

return $field;
}

/**
Expand All @@ -195,16 +199,22 @@ public function getManyField()
->addComponent(new GridFieldOrderableRows($this->getSortColumn()))
->addComponent(new GridFieldEditButton())
->addComponent(new GridFieldDeleteAction(false));

$config->getComponentByType(GridFieldDataColumns::class)
->setDisplayFields([
'Layout' => _t(__CLASS__ . '.LINK', 'Link')
]);
return GridField::create(

$field = GridField::create(
$this->name,
$this->title,
$this->parent->{$this->name}(),
$config
)->setForm($this->Form);

$this->extend('updateManyField', $field);

return $field;
}

/**
Expand Down

0 comments on commit fdd3723

Please sign in to comment.