silvershop / silverstripe-hasonefield
Edit a has_one relationship using a GridField, triggered by clicking a button.
Installs: 249 912
Dependents: 19
Suggesters: 0
Security: 0
Stars: 32
Watchers: 5
Forks: 27
Open Issues: 5
Type:silverstripe-vendormodule
Requires
- silverstripe/framework: ^4.0
- silverstripe/vendor-plugin: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
Replaces
- dev-main / 3.x-dev
- 3.1.0
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.x-dev
- 2.1.1
- 2.1.0
- 2.0.0
- 2.0-alpha2
- 2.0-alpha1
- 1.x-dev
- 1.0.0
- dev-dependabot/npm_and_yarn/minimatch-3.0.8
- dev-dependabot/npm_and_yarn/ua-parser-js-0.7.33
- dev-dependabot/npm_and_yarn/qs-6.5.3
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
This package is auto-updated.
Last update: 2023-05-11 19:14:55 UTC
README
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.
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
.
Filtering Results
To filter the results shown in the picker use HasOneAddExistingAutoCompleter::setSearchList
.
$property = HasOneButtonField::create( $this, 'Address' ); $property ->getConfig() ->getComponentByType(HasOneAddExistingAutoCompleter::class) ->setSearchList(Property::get()->filter("Country", "GB")); $fields->addFieldToTab( 'Root.Main', $property );