hailwood/silverstripe-simple-linkfield

This package is abandoned and no longer maintained. No replacement package was suggested.

Adds a new simple linkfield fieldtype.

v1.0.0 2017-01-25 22:16 UTC

This package is not auto-updated.

Last update: 2020-06-12 19:39:35 UTC


README

A Silverstripe Link Field:

Screenshot

  • user defined protocols: Any are supported and depending on the option selected (http, https, or mailto) we'll validate it.

Installation

composer require hailwood/silverstripe-simple-linkfield

Options

TextLinkField:
  default_protocols:
    http: 'http://'
    https: 'https://'
    mailto: 'Email'

Usage

Dataobject/Page
class DataObjectWithLink extends DataObject {

    protected static $db = [
        'Link' => 'Varchar(255)',
        'LinkWithoutEmail' => 'Varchar(255)',
    ];
    
    public function getCMSFields(){
        $fields = parent::getCMSFields();
        
        $fields->addFieldsToTab('Root.Main', [
            TextLinkField::create('Link', 'Link'),
            TextLinkField::create('LinkWithoutEmail')->withoutEmailOption()
        ]);
        
        return $fields;
    }

}
Methods
  • withoutEmailOption(): Quickly disable the default email option
  • withEmailOption($title = 'Email'): Quickly enable or set the title on the default email option
  • setProtocolList([]): Set the local instances protocol list
  • getProtocolList(): Get the list of protocols in use by this local instance