goldfinch/fielder

Field is fields manager and orginizer for Silverstripe

Installs: 626

Dependents: 17

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

v2.0.23 2024-08-19 00:22 UTC

README

Silverstripe Version Package Version Total Downloads License

Fielder 🚜 is fields organizer that helps to simplify fields declaration and makes it easy to manage all in one place, keeping it clean with less code.

Install

composer require goldfinch/fielder

Usage

Fielder within the cms fields in DataObject

use SilverStripe\ORM\DataObject;

MyAwesomeModel extends DataObject
{
    public function getCMSFields()
    {
        $fields = parent::getSettingsFields()->initFielder($this);
        
        $fielder = $fields->getFielder();

        $fielder->remove('Content');

        $fielder->required([
            'FirstName',
            'About',
        ]);

        $fielder->fields([
            'Root.Main' => [
                $fielder->string('FirstName', 'First name'),
                $fielder->text('About'),
                $fielder->html('Content'),
            ],
            'Root.Demo' => [
                $fielder->string('Headline'),
            ],
        ]);

        return $fields;
    }
}

Fielder within the settings fields in SiteTree

use SilverStripe\CMS\Model\SiteTree;

MyAwesomePage extends SiteTree
{
    public function getSettingsFields()
    {
        $fields = parent::getSettingsFields()->initFielder($this);

        $fielder = $fields->getFielder();
        
        $fielder->remove('ShowInMenus');

        return $fields;
    }
}

Fielder has its own validator method to ease validation process (see validate method). Having said that the default SS validation method can still be presented and will be called alongside.

use SilverStripe\ORM\DataObject;

MyAwesomeModel extends DataObject
{
    public function getCMSFields()
    {
        $fields = parent::getSettingsFields()->initFielder($this);
        
        $fielder = $fields->getFielder();
        
        // fielder validation
        $fielder->validate([
            'Email' => 'required|email'
        ]);

        return $fields;
    }

    // default SS validation
    public function validate()
    {
        $result = parent::validate();

        if ($this->Title != 'Home') {
            $result->addError('Title is invalid');
        }

        return $result;
    }
}

Fielder in extension

use SilverStripe\ORM\DataExtension;

class MyExtension extends DataExtension
{
    public function updateCMSFields($fields)
    {
        $fields->initFielder($this->owner);

        $fielder = $fields->getFielder();

        $fielder->validate([
            'Email' => 'required|email',
        ]);
    }

    public function updateSettingsFields($fields)
    {
        $fields->initFielder($this->owner);

        $fielder = $fields->getFielder();

        $fielder->remove('ShowInMenus');
    }
}

List of available methods

declare fields in tabs

$fielder->fields([
  'Root.Main' => [
    $fielder->string('Title'),
  ],
])

declare fields removing previously declared fields

$fielder->freshFields([
  'Root.Main' => [
    $fielder->string('Title'),
  ],
])

insert after

$fielder->insertAfter('MenuTitle', $fielder->string('Title'));

$fielder->insertAfter('MenuTitle', [
    $fielder->string('Title'),
    $fielder->text('Content'),
]);

insert before

$fielder->insertBefore('MenuTitle', $fielder->string('Title'));

$fielder->insertBefore('MenuTitle', [
    $fielder->string('Title'),
    $fielder->text('Content'),
]);

reorder fields

$fielder->reorder(['Content', 'MenuTitle']);

reorder tabs

$fielder->reorderTabs([
    'Root.Demo',
    'Root.Main'
]);

add fields to tab

$fielder->toTab('Root.Demo', [
    $fielder->string('Title'),
    $fielder->text('Content'),
]);

get data field, same as dataFieldByName

$fielder->dataField('Title');

get field, same as scaffoldFormField

$fielder->field('Title');

required field

$fielder->required('Title')
$fielder->required(['Title', 'Content']);

//through validate method (recommended)

$fielder->validate([
    'Title' => 'required',
]);

remove specific fields

$fielder->remove('Title');

remove all fields

$fielder->removeAll();

remove all fields within the class (ignores fields that were added through inherited or extended classes)

$fielder->removeAllCurrent();

remove fields in tab

$fielder->removeFieldsInTab('Root.Main');
// same as
$fielder->clearTab('Root.Main');

add description field

$fielder->description('Title', 'Some field description flies here');
// ..
$fielder->description([
    'Title' => 'Some field description flies here',
    'URLSegment' => '<strong style="color: red">Red field description</strong>'
]);

disable field

$fielder->disable('Title');
$fielder->disable('Title', false); // undisabled
// ..
$fielder->disable(['Title', 'Text']);
$fielder->disable(['Title', 'Text'], false); // undisabled all

readonly field

$fielder->readonly('Title');
$fielder->readonly('Title', false); // take off readonly
// ..
$fielder->readonly(['Title', 'Text']);
$fielder->readonly(['Title', 'Text'], false); // take off readonly

add custom error

$fielder->addError('Error message'); // error | required | bad | validation
$fielder->addError('Error message', 'info');
$fielder->addError('Error message', 'warning');
$fielder->addError('Error message', 'message');
$fielder->addError('<strong>Error</strong> message', 'good', null, 'html');

validate fields

Basic closure validation per each field

$fielder->validate([
    'Title' => function($value, $fail) {
        $max = 100;
        if (strlen($value) > $max) {
            $fail('The :attribute must not be over ' . $max . ' characters.');
        }
    }
]);

Laravel approach (recommended)

This package comes with Laravel validation components that are ready to use. For more info on what rules are available and how to use them, please refer to this list

use Goldfinch\Illuminate\Rule;

$fielder->validate([
    'Title' => 'required|regex:/^[\d\s\+\-]+$/',
    'Email' => 'required|email',
    'Fruits' => ['required', Rule::in(['apple', 'orange', 'kiwi'])],
]);

You can also create a custom rule that will handle your specific validation logic. Use Taz🌪️ to create a new rule.

eg:

php taz make:rule PhoneRule

and simply implement it in your validation rules:

use App\Rules\PhoneRule;

$fielder->validate([
    'Phone' => ['required', new PhoneRule()],
]);

display logic methods

Basic coverage, not all functions are yet available.

$fielder->displayIf();
$fielder->displayUnless();
$fielder->hideIf();
$fielder->hideUnless();

examples:

$fielder->toTab('Root.Demo', [
    $fielder->checkbox('ConditionalField'),
    $fielder->displayIf('ConditionalField', [ // isChecked
    // $fielder->displayIf('!Magic', [ // isNotChecked
    // $fielder->displayIf(['MagicString', '==', null], [ // isEmpty
    // $fielder->displayIf(['MagicString', '!=', null], [ // isNotEmpty
    // $fielder->displayIf(['MagicString', '==', 3], [ // isEqualTo
    // $fielder->displayIf(['MagicString', '==', [2,3]], [ // isEqualTo
    // $fielder->displayIf(['MagicString', '!=', 3], [ // isNotEqualTo
    // $fielder->displayIf(['MagicString', '!=', [2,3]], [ // isNotEqualTo
    // $fielder->displayIf(['MagicString', '>', 3], [ // isGreaterThan
    // $fielder->displayIf(['MagicString', '<', 3], [ // isLessThan
        $fielder->string('Field1'),
        $fielder->string('Field2'),
        $fielder->string('Field3'),
    ])
]);

List of available fields

✳️ General fields

checkbox

Checkbox field

Class: SilverStripe\Forms\CheckboxField

Suitable DB Type: Boolean

$fielder->checkbox($name, $title = null, $value = null)

// left aligned checkbox (wrapped in composite field)
$fielder->lineCheckbox($name, $title = null, $value = null)

dropdown

Dropdown field

Class: SilverStripe\Forms\DropdownField

Suitable DB Type: *

$fielder->dropdown($name, $title = null, $source = [], $value = null)

readonly

Readonly field

Class: SilverStripe\Forms\ReadonlyField

Suitable DB Type: *

$fielder->readonlyField($name, $title = null, $value = null)

text

Textarea field

Class: SilverStripe\Forms\TextareaField

Suitable DB Type: *

$fielder->text($name, $title = null, $value = null)

string

Text field

Class: SilverStripe\Forms\TextField

Suitable DB Type: Varchar

$fielder->string($name, $title = null, $value = '', $maxLength = null, $form = null)

password

Password field

Class: SilverStripe\Forms\PasswordField

Suitable DB Type: Varchar

$fielder->password($name, $title = null, $value = '')

action

Action field

Class: SilverStripe\Forms\FormAction

$fielder->action($action, $title = '', $form = null)

passwordConfirmed

Password confirm field

Class: SilverStripe\Forms\ConfirmedPasswordField

Suitable DB Type: *

$fielder->passwordConfirmed($name, $title = null, $value = '', $form = null, $showOnClick = false, $titleConfirmField = null)

currency

Currency field

Class: SilverStripe\Forms\CurrencyField

Suitable DB Type: Currency

$fielder->currency($name, $title = null, $value = '', $maxLength = null, $form = null)

date

Date field

Class: SilverStripe\Forms\DateField

Suitable DB Type: Date

$fielder->date($name, $title = null, $value = '', $maxLength = null, $form = null)

datetime

Datetime field

Class: SilverStripe\Forms\DatetimeField

Suitable DB Type: Datetime

$fielder->datetime($name, $title = null, $value = '', $maxLength = null, $form = null)

email

Email field

Class: SilverStripe\Forms\EmailField

Suitable DB Type: Varchar

$fielder->email($name, $title = null, $value = '', $maxLength = null, $form = null)

groupedDropdown

Grouped dropdown field

Class: SilverStripe\Forms\GroupedDropdownField

Suitable DB Type: *

$fielder-> groupedDropdown($name, $title = null, $source = [], $value = null)
// ..
$fielder->groupedDropdown('Name', 'Title', [
    'numbers' => [1 => 1, 2 => 2],
    'letters' => [1 => 'A', 2 => 'B'],
])
// $source = FooBar::get()->map()

html

HTML Editor field

Class: SilverStripe\Forms\HTMLEditor\HTMLEditorField

Suitable DB Type: HTMLText

$fielder->html($name, $title = null, $value = '', $config = null)

money

Money field

Class: SilverStripe\Forms\MoneyField

Suitable DB Type: Money

$fielder->money($name, $title = null, $value = '')

numeric

Numeric field

Class: SilverStripe\Forms\NumericField

Suitable DB Type: Decimal Float Int

$fielder->numeric($name, $title = null, $value = '', $maxLength = null, $form = null)

radio

Radio field

Class: SilverStripe\Forms\OptionsetField

Suitable DB Type: *

$fielder->radio($name, $title = null, $source = [], $value = null)
// ..
$fielder->radio('Name', 'Title', [1 => 'Option 1', 2 => 'Option 2'])
// $source = FooBar::get()->map()

selectionGroup

Selection group field

Class: SilverStripe\Forms\SelectionGroup

Suitable DB Type: *

$fielder->selectionGroup($name, $items, $value = null)
// ..
$fielder->selectionGroup('Name', [
    $fielder->selectionGroupItem(
        'one',
        $fielder->literal('one', 'one view'),
        'one title'
    ),
    $fielder->selectionGroupItem(
        'two',
        $fielder->literal('two', 'two view'),
        'two title'
    ),
])

time

Time field

Class: SilverStripe\Forms\TimeField

Suitable DB Type: Time

$fielder->time($name, $title = null, $value = '', $maxLength = null, $form = null)

✳️ Structure fields

composite

Composite field

Class: SilverStripe\Forms\CompositeField

$fielder->composite($children = null)
// ..
$fielder->composite([
    $fielder->string('Title'),
    $fielder->html('Text'),
])

group

Group field

Class: SilverStripe\Forms\FieldGroup

$fielder->group($titleOrField = null, ...$otherFields)
// ..
$fielder->group(
    'Group name',
    $fielder->string('Title'),
    $fielder->html('Text'),
)

list

List field. FYI: $fields is FieldList already. Using this field we store new FieldList in FieldList

Class: SilverStripe\Forms\FieldList

$fielder->list($items = [])
// ..
...$fielder->list([
    $fielder->string('Title'),
    $fielder->html('Text'),
])

tab

Tab field

Class: SilverStripe\Forms\Tab

$fielder->tab($name, $titleOrField = null, $fields = null)
// ..
$fielder->tab('Primary tab', $fielder->header('Header'), $fielder->literal('Literal', '<b>Br</b>eaking <b>Ba</b>d'))

tabSet

Tab set field

Class: SilverStripe\Forms\TabSet

$fielder->tabSet($name, $titleOrTab = null, $tabs = null)
// ..
$fielder->tabSet('MyTabSetName',
    $fielder->tab('Primary tab', $fielder->header('Header'), $fielder->literal('Literal', '<b>Br</b>eaking <b>Ba</b>d')),
    $fielder->tab('Secondary tab', $fielder->header('Header'), $fielder->literal('Literal', '<b>Banshee</b>')),
)

toggleComposite

Toggle composite field

Class: SilverStripe\Forms\ToggleCompositeField

$fielder->toggleComposite($name, $title, $children)
// ..
$fielder->toggleComposite('MyToggle', 'Toggle', [
    $fielder->string('Title'),
    $fielder->text('Text')
])

✳️ File fields

upload

Upload field

Class: SilverStripe\AssetAdmin\Forms\UploadField

Suitable relationship: has_one has_many many_many belongs_many_many

$fielder->upload($name, $title = null, SS_List $items = null)

file

File field

Class: SilverStripe\Forms\FileField

Suitable relationship: has_one has_many many_many belongs_many_many

$fielder->file($name, $title = null, $value = null)

✳️ Relationship fields

checkboxSet

Checkbox set field

Class: SilverStripe\Forms\CheckboxSetField

Suitable relationship: has_many many_many belongs_many_many

$fielder->checkboxSet($name, $title = null, $source = [], $value = null)
// ..
$fielder->checkboxSet('List', 'List', [1 => 'Set 1', 2 => 'Set 2']),
// $source = FooBar::get()->map()

dropdownTree

Dropdown tree field (!SiteTree)

Class: SilverStripe\Forms\TreeDropdownField

Suitable relationship: has_one

$fielder->dropdownTree($name, $title = null, $sourceObject = null, $keyField = 'ID', $labelField = 'TreeTitle', $showSearch = true)
// ..
$fielder->dropdownTree('Page')

treeMultiSelect

Tree Multiselect field, only for SilverStripe\Security\Group

Class: SilverStripe\Forms\TreeMultiselectField

Suitable relationship: has_many many_many

$fielder->treeMultiSelect($name, $title = null, $sourceObject = Group::class, $keyField = "ID", $labelField = "Title")

grid

Grid field

Class: SilverStripe\Forms\GridField\GridField Goldfinch\Fielder\Grid

Suitable relationship: has_many many_many belongs_many_many

$fielder->grid($name, $title = null, SS_List $dataList = null, GridFieldConfig $config = null)
// ..
$fielder->grid('Services', 'Services')->build()
// ..
$fielder->grid('Services', 'Services', $this->Services())->build()
// ..
$fielder->grid('Cards', 'Cards')
    ->config('default')
    ->components([
        'add',
        'edit',
    ])
    ->remove([
        'add',
        'edit',
        'copy',
        'delete',
    ])->build()
  • might require additional packages

listbox

Listbox field

Class: SilverStripe\Forms\ListboxField

Suitable relationship: has_many many_many belongs_many_many

$fielder->listbox($name, $title = null, $source = [], $value = null, $size = null)

✳️ Utility fields

header

Header field

Class: use SilverStripe\Forms\HeaderField;

$fielder->header($name, $title = null, $headingLevel = 2)

hidden

Hidden field

Class: SilverStripe\Forms\HiddenField

Suitable DB Type: *

$fielder->hidden($name, $title = null, $value = null)

label

Label field

Class: SilverStripe\Forms\LabelField

$fielder->label($name, $title = null)

literal

Literal field

Class: SilverStripe\Forms\LiteralField

$fielder->literal($name, $content)

nullable

Nullable field

Class: SilverStripe\Forms\NullableField

Suitable DB Type: *

$fielder->nullable(FormField $valueField, $isNullLabel = null)
// ..
$fielder->nullable($fielder->string('Text'))

decimal

Decimal (DB) field

Class: SilverStripe\ORM\FieldType\DBDecimal

Suitable DB Type: Decimal

$fielder->decimal($name, $title = null, $wholeSize = 9, $decimalSize = 2, $defaultValue = 0)

double

Double (DB) field

Class: SilverStripe\ORM\FieldType\DBDouble

Suitable DB Type: Double

$fielder->double($name, $title = null, $defaultVal = 0)

float

Float (DB) field

Class: SilverStripe\ORM\FieldType\DBFloat

Suitable DB Type: Float

$fielder->float($name, $title = null, $defaultVal = 0)

year

Year (DB) field

Class: SilverStripe\ORM\FieldType\DBYear

Suitable DB Type: Year

$fielder->year($name, $title = null, $options = [])

percentage

Percentage (DB) field

Class: SilverStripe\ORM\FieldType\DBPercentage

Suitable DB Type: Percentage | Percentage(6)

$fielder->percentage($name, $title = null, $precision = 4)

integer

Integer (DB) field

Class: SilverStripe\ORM\FieldType\DBInt

Suitable DB Type: Int

$fielder->int($name, $title = null, $defaultVal = 0)

big integer

Big Integer (DB) field

Class: SilverStripe\ORM\FieldType\DBBigInt

Suitable DB Type: BigInt

$fielder->bigInt($name, $title = null, $defaultVal = 0)

locale

Locale (DB) field

Class: SilverStripe\ORM\FieldType\DBLocale

Suitable DB Type: Locale

$fielder->locale($name, $title = null, $size = 16)

enum

Enum (DB) field

Class: SilverStripe\ORM\FieldType\DBEnum

Suitable DB Type: Enum("Apple,Orange,Kiwi", "Kiwi")

$fielder->enum($name)

siteTreeURLSegment

SiteTreeURLSegment field

Class: SilverStripe\CMS\Forms\SiteTreeURLSegmentField

Suitable DB Type: *

$fielder->siteTreeURLSegment($name, $title = null, $value = '', $maxLength = null, $form = null)

htmlReadonly

HTMLReadonly field

Class: SilverStripe\Forms\HTMLReadonlyField

Suitable DB Type: *

$fielder->htmlReadonly($name, $title = null, $value = null)

✳️ External fields

shortcode

composer require goldfinch/shortcode

Shortcode field (string)

Suitable DB Type: SCVarchar

$fielder->shortcode($name, $title = null)

objectLink

composer require silvershop/silverstripe-hasonefield dev-main

HasOneButton field

Class: SilverShop\HasOneField\HasOneButtonField

Suitable relationship: has_one belongs_to

$fielder->objectLink($relationName, $fieldName = null, $title = null, GridFieldConfig $customConfig = null, $useAutocompleter = true)

object

composer require gorriecoe/silverstripe-linkfield ^1.1

HasOneLink field

Class: gorriecoe\LinkField\Forms\HasOneLinkField

Suitable relationship: has_one belongs_to

$fielder->object($relationName, $title = null, $linkConfig = [], $useAutocompleter = false)

multiSelect

composer require kinglozzer/multiselectfield ^2.0

MultiSelect field

Class: Kinglozzer\MultiSelectField\Forms\MultiSelectField

Suitable relationship: many_many belongs_many_many

$fielder->multiSelect($name, $title = null, $sort = false, $source = null, $titleField = 'Title')
// ..
$fielder->multiSelect('Services'),
$fielder->multiSelect('Services', 'Services', 'SortExtra'),

media

composer require goldfinch/image-editor

EditableUpload field

Class: Goldfinch\ImageEditor\Forms\EditableUploadField

Suitable relationship: has_one has_many many_many belongs_many_many

...$fielder->media($name, $title = null)

mediaSortable

composer require goldfinch/image-editor

EditableSortableUpload field

Class: Goldfinch\ImageEditor\Forms\EditableSortableUploadField

Suitable relationship: has_many many_many belongs_many_many

...$fielder->mediaSortable($name, $title = null)

color

composer require heyday/silverstripe-colorpalette ^2.1

ColorPalette field

Class: Heyday\ColorPalette\Fields\ColorPaletteField

Suitable DB Type: *

$fielder->color($name, $title = null, $source = [], $value = null)
// ..
$fielder->color('Color', 'Color', ['yellow' => '#fee12f', 'pink' => '#eb83ad', 'green' => '#70cd77'])

colorPicker

composer require ryanpotter/silverstripe-color-field ^1.0

Color field

Class: RyanPotter\SilverStripeColorField\Forms\ColorField

Suitable DB Type: *

$fielder->colorPicker($name, $title = null, $value = '', $form = null)

Additional requirements:

# yml config (example)
RyanPotter\SilverStripeColorField\Forms\ColorField:
  colors:
    - '#1976D2'
    - '#2196F3'

colorGroup

composer require heyday/silverstripe-colorpalette ^2.1

GroupedColorPalette field

Class: Heyday\ColorPalette\Fields\GroupedColorPaletteField

Suitable DB Type: *

$fielder->colorGroup($name, $title = null, $source = [], $value = null)
// ..
$fielder->colorGroup('Color', 'Color', ['Primary' => ['yellow' => '#fee12f', 'pink' => '#eb83ad'], 'Secondary' => ['green' => '#70cd77']])

json

composer require goldfinch/json-editor

JSONEditor field

Class: Goldfinch\JSONEditor\Forms\JSONEditorField

Suitable DB Type: JSONText Goldfinch\JSONEditor\ORM\FieldType\DBJSONText::class

$fielder->json($name, $title = null, $options = [], $value = '{}', $form = null, $schema = '{}')

Additional requirements:

  1. create schema fiel: app/_schema/Page-Parameters.json (app/_schema/{parent-classname}-{field-mame}.json)

  2. example schema file:

{
  "type": "array",
  "options": {},
  "items": {
    "type": "object",
    "properties": {
      "example": {
        "title": "Example",
        "type": "string",
        "default": "default example text"
      }
    }
  }
}
  1. example field
$fielder->json('Parameters')

video

composer require goldfinch/video-field

Video field

Class: Goldfinch\VideoField\Forms\VideoField

Suitable DB Type: Video

$fielder->video($name, $title = null, $value = '', $static = false)

See: github.com/goldfinch/video-field

place

composer require goldfinch/google-fields

Place field

Class: Goldfinch\GoogleFields\Forms\PlaceField

Suitable DB Type: Place

$fielder->place($name, $title = null, $value = '')

Additional requirements:

.env

APP_GOOGLE_MAPS_KEY=''

See: github.com/goldfinch/google-fields

map

composer require goldfinch/google-fields

Map field

Class: Goldfinch\GoogleFields\Forms\MapField

Suitable DB Type: Map

$fielder->map($name, $title = null, $value = '')

Additional requirements:

.env

APP_GOOGLE_MAPS_KEY=''

See: github.com/goldfinch/google-fields

link

composer require maxime-rainville/anyfield ^0.0.0

Checkbox field

Class: SilverStripe\AnyField\Form\AnyField

Suitable relationship: has_one Relationship type: SilverStripe\LinkField\Models\Link::class

Template: vendor/silverstripe/linkfield/templates/SilverStripe/LinkField/Models/Link.ss

$fielder->link($name, $title = null, $value = null)

links

composer require maxime-rainville/anyfield ^0.0.0

ManyAny field

Class: SilverStripe\AnyField\Form\ManyAnyField

Suitable relationship: has_many many_many belongs_many_many Relationship type: SilverStripe\LinkField\Models\Link::class

$fielder->links($name, $title = null, SS_List $dataList = null)

Additional requirements:

Required $has_one on SilverStripe\LinkField\Models\Link

eg:

private static $has_one = [
    'Page' => \Page::class,
];

linkSS

composer require silverstripe/linkfield ^3

Link field

Class: SilverStripe\LinkField\Form\LinkField

Suitable relationship: has_many many_many belongs_many_many Relationship type: SilverStripe\LinkField\Models\Link::class

$fielder->linkSS($name, $title = null, $value = null)

linkRel (extra link field)

composer require gorriecoe/silverstripe-linkfield ^1.1

Link field

Class: gorriecoe\LinkField\LinkField

Suitable relationship: has_one Relationship type: gorriecoe\Link\Models\Link::class

$fielder->linkRel($name, $title = null, $linkConfig = [])
// ..
$fielder->linkRel('ALink', 'Link')

code

composer require kevingroeger/codeeditorfield ^1.2

CodeEditor field

Class: KevinGroeger\CodeEditorField\Forms\CodeEditorField

Suitable DB Type: *

$fielder->code($name, $title = null, $value = null, $mode = 'ace/mode/html', $theme = 'ace/theme/github')

tag

composer require silverstripe/tagfield ^3.0

Tag field

Class: SilverStripe\TagField\TagField

Suitable relationship: has_many many_many belongs_many_many

$fielder->tag($name, $title = null, $source = [], $value = null, $titleField = 'Title')

points

composer require goldfinch/silverstripe-image-points

Point field

Class: LittleGiant\SilverStripeImagePoints\DataObjects\Point

Suitable relationship: has_many many_many belongs_many_many

$fielder->points($name, $title = null, $source = [], $gridconfig = null)

Additional requirements:

  1. model
use LittleGiant\SilverStripeImagePoints\DataObjects\Point;
use SilverStripe\Assets\Image;

private static $has_one = [
    'Image' => Image::class,
];

private static $has_many = [
    'ImagePoints' => Point::class . '.PointOf',
];

private static $owns = [
    'Image',
];
  1. yml config
LittleGiant\SilverStripeImagePoints\DataObjects\Point:
  image_width: 1918
  image_height: 822
  1. example field
$fielder->points('ImagePoints')

wrapper

composer require unclecheese/display-logic

Wrapper field

Class: UncleCheese\DisplayLogic\Forms\Wrapper

$fielder->wrapper($children)

autocomplete

composer require tractorcow/silverstripe-autocomplete ^5.0

Autocomplete field

Class: TractorCow\AutoComplete\AutoCompleteField

Suitable DB Type: *

$fielder->autocomplete($name, $title = null, $value = '', $sourceClass = null, $sourceFields = null)
// ..
$fielder->autocomplete('Page', 'Page', '', Page::class, 'Title')

stringTag

composer require silverstripe/tagfield ^3.0

StringTag field

Class: SilverStripe\TagField\StringTagField

Suitable DB Type: *

$fielder->stringTag($name, $title = null, $source = [], $value = null)
// ..
$fielder->stringTag('Varchar', 'Varchar', MyDataObject::get())

imageCoords

composer require goldfinch/image-editor

ImageCoords field

Class: Goldfinch\ImageEditor\Forms\ImageCoordsField

Suitable relationship: has_one

$fielder->imageCoords($name, $title, $onlyCanvas = false, $cssGrid = false, $image = null, $XFieldName = null, $YFieldName = null, $xySumFieldName = null, $width = null, $height = null)
// ..
$fielder->imageCoords('Image', 'Focus Point', true)
$fielder->imageCoords('Image', 'Focus Point')

encrypt

composer require lekoala/silverstripe-encrypt dev-master

Encrypt field

Class: LeKoala\Encrypt\EncryptHelper

Suitable DB Type:

'MyText' => LeKoala\Encrypt\EncryptedDBText::class,
'MyHTMLText' => LeKoala\Encrypt\EncryptedDBHTMLText::class,
'MyVarchar' => LeKoala\Encrypt\EncryptedDBVarchar::class,
'MyNumber' => LeKoala\Encrypt\EncryptedNumberField::class,
'MyIndexedVarchar' => LeKoala\Encrypt\EncryptedDBField::class,
$fielder->encrypt($name)

country

composer require dynamic/silverstripe-country-dropdown-field ^2.0

CountryDropdown field

Class: Dynamic\CountryDropdownField\Fields\CountryDropdownField

Suitable DB Type: *

$fielder->country($name, $title = null, $source = [], $value = '', $form = null)

icon

composer require goldfinch/icon-field

Icon field

Class: Goldfinch\IconField\Forms\IconField

Suitable DB Type: Icon Goldfinch\IconField\ORM\FieldType\DBIcon::class

$fielder->icon($set, $name, $title = null, $value = '')

Additional requirements:

Set .yml config github.com/goldfinch/icon-field

phone

composer require innoweb/silverstripe-international-phone-number-field dev-master

Phone (DB) field

Class: Innoweb\InternationalPhoneNumberField\ORM\DBPhone

Suitable DB Type: Phone

$fielder->phone($name, $title = null, $options = [])

Template output

$Phone.International
$Phone.National
$Phone.E164
$Phone.RFC3966
$Phone.URL
<% if Phone %>
<% with Phone %>
<a href="$URL" title="$International">$National</a>
<% end_with %>
<% end_if %>

mediaSelect

composer require goldfinch/silverstripe-imageselection-field

Phone (DB) field

Class: NSWDPC\Forms\ImageSelectionField\ImageSelectionField

Suitable relationship:

'Image' => Image::class,
'Images' => Image::class,
$fielder->mediaSelect($name, $relationList, $title = null)
// ..
$fielder->mediaSelect('Image', 'Images')

Template output

$Phone.International
$Phone.National
$Phone.E164
$Phone.RFC3966
$Phone.URL

License

The MIT License (MIT)