From cc21f8acc3fe3b0ba04b6585763372596aca1065 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 29 Nov 2023 14:48:08 +1300 Subject: [PATCH] DOC Update README --- README.md | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 6a482a8c..d737a86f 100644 --- a/README.md +++ b/README.md @@ -19,22 +19,10 @@ This module provides a Link model and CMS interface for managing different types Installation via composer. -### Silverstripe 5 - ```sh composer require silverstripe/linkfield ``` -### GraphQL v4 - Silverstripe 4 - -`composer require silverstripe/linkfield:^2` - -### GraphQL v3 - Silverstripe 4 - -```sh -composer require silverstripe/linkfield:^1 -``` - ## Sample usage ```php @@ -43,6 +31,7 @@ use SilverStripe\CMS\Model\SiteTree; use SilverStripe\LinkField\ORM\DBLink; use SilverStripe\LinkField\Models\Link; use SilverStripe\LinkField\Form\LinkField; +use SilverStripe\LinkField\Form\MultiLinkField; class Page extends SiteTree { @@ -50,15 +39,22 @@ class Page extends SiteTree 'HasOneLink' => Link::class, ]; + private static $has_many = [ + 'HasManyLinks' => Link::class + ]; + public function getCMSFields() { $fields = parent::getCMSFields(); + // Don't forget to remove the auto-scaffolded fields! + $fields->removeByName(['HasOneLinkID', 'Links']); + $fields->addFieldsToTab( 'Root.Main', [ LinkField::create('HasOneLink'), - LinkField::create('DbLink'), + MultiLinkField::create('HasManyLinks'), ], ); @@ -67,13 +63,7 @@ class Page extends SiteTree } ``` -## Migrating from Version `1.0.0` or `dev-master` - -Please be aware that in early versions of this module (and in untagged `dev-master`) there were no table names defined -for our `Link` classes. These have now all been defined, which may mean that you need to rename your old tables, or -migrate the data across. - -EG: `SilverStripe_LinkField_Models_Link` needs to be migrated to `LinkField_Link`. +Note that you also need to add a `has_one` relation on the `Link` model to match your `has_many` here. See [official docs about `has_many`](https://docs.silverstripe.org/en/developer_guides/model/relations/#has-many) ## Migrating from Shae Dawson's Linkable module @@ -82,4 +72,4 @@ https://github.com/sheadawson/silverstripe-linkable Shae Dawson's Linkable module was a much loved, and much used module. It is, unfortunately, no longer maintained. We have provided some steps and tasks that we hope can be used to migrate your project from Linkable to LinkField. -* [Migraiton docs](docs/en/linkable-migration.md) +* [Migration docs](docs/en/linkable-migration.md)