Download the PHP package maxime-rainville/anyfield without Composer
On this page you can find all versions of the php package maxime-rainville/anyfield. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maxime-rainville/anyfield
More information about maxime-rainville/anyfield
Files in maxime-rainville/anyfield
Package anyfield
Short Description Add Silverstripe CMS field that can be used to manage any relation
License BSD-3-Clause
Informations about the package anyfield
Silverstripe CMS AnyField module
This module provides two simple form fields to manage has-one and has-many relations for a parent record.
AnyField
and ManyAnyField
are best suited to managing simple DataObjects that are tightly coupled to their owner. This module will not work well for DataObjects with complex relations.
silverstripe/linkfield
is a great complement to the AnyField
.
Installation
This module require Silverstripe CMS 5 or greater.
Showcase
- Manage
has_one
orhas_many
relations with ease - Manage multiple Dataobject classes from a single field
- Allow your content authors to edit your child DataObjects from a modal within their parent page
- Works in regular Entwine forms and Elemental blocks.
Sample usage
Customising how DataObject look in the field
Any DataObject can be managed by the AnyField and ManyAnyField without any special tweaks. However, you can get a bit more value with some simple tweaks. Those tweaks can be applied with DataExtension.
Customising the Title
The AnyFields displays the selected DataObject title. By defining a getTitle
method for DataObject class, you can customise the title displayed in the field.
Showing a summary
The AnyFields displays the type of the selected DataObject below its title. You can also display a summary by implementing a getSummary
method on your DataObject class. This can be done with a DataExtension as well.
Showing an icon
You can customise the icon to display for each class of DataObject by defining a private static $icon
config value for your DataObject.
Silverstripe CMS comes with some predefined icons you can use. Alternatively, the icon
value will be add as a CSS class to the relevant button which you can then target with your own custom icon.
Sorting the ManyManyField
ManyManyField
can be configured to sort its results. Called setSort
to define what field should be used to sort the results
A convenience extension can be applied to your DataObject classes to add the required field to make them sortable. The extension will automatically add a Sort
integer field, define the default sort order and hide the Sort
field from the CMS form.
Advanced use case
Auto-publishing and cascade deleting
The AnyFields doesn't allow you to publish or delete child DataObjects independently from their owner. To avoid orphan objects or unpublished DataObject, you should explicitly define ownership and cascade rules on the owner DataObject class.
Controlling what DataObject class can be created via the AnyFields
AnyField and ManyAnyField try to automatically detect what DataObject classes they are meant to manage by looking up the matching relations on their parent object.
If you decide to name the AnyFields something other than its intended relation, you'll have to explicitly tell it what DataObject class to use.
By the default, the AnyField automatically discovers any sub classes of the base class and allows the end user to create those sub classes. You can turn off this behaviour by calling setRecursivelyAddChildClass
.
You can also exclude individual classes as well.
All versions of anyfield with dependencies
silverstripe/framework Version ^5
silverstripe/admin Version ^2
league/uri Version ^7.1
league/uri-components Version ^7.1
maxime-rainville/silverstripe-react Version ^0.1