This package is abandoned and no longer maintained. The author suggests using the silvershop/silverstripe-hasonefield package instead.

Edit a has_one relationship using the gridfield editor, triggered by clicking a button.

Installs: 1 551

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 25


2.0.0 2018-02-05 10:43 UTC

This package is auto-updated.

Last update: 2022-02-01 13:14:16 UTC


Allows you to create a CMS button for creating and editing a single related object. It is actually a grid field, but just looks like a button.



In Warehouse.php context:

    use SilverShop\HasOneField\HasOneButtonField;

	public function getCMSFields() {
		$fields = parent::getCMSFields();
			$fields->addFieldsToTab("Root.Main", array(
				ReadonlyField::create("add", "Address", $this->Address()->toString())
            // $dataObject, 'RelationName', 'Optional title - would default to Relation Name'
			HasOneButtonField::create($this, "Address") //here!

		return $fields;

You must pass through the parent context ($this), so that the has_one relationship can be set by the GridFieldDetailForm.