Skip to content

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

Notifications You must be signed in to change notification settings

MasonD/silverstripe-hasonefield

 
 

Repository files navigation

SilverStripe has_one field

Build Status Latest Stable Version Latest Unstable Version

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.

demo

Installation

composer require silvershop/silverstripe-hasonefield

Usage

    use SilverShop\HasOneField\HasOneButtonField;

    private static $has_one = [
        'Address' => 'Address'
    ];

    public function getCMSFields() {
        $fields = parent::getCMSFields();

        $fields->addFieldToTab("Root.Main",
            HasOneButtonField::create($this, "Address")
        );

        return $fields;
    }

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 87.6%
  • JavaScript 8.9%
  • Scheme 2.6%
  • CSS 0.9%