hailwood / silverstripe-simple-linkfield
Adds a new simple linkfield fieldtype.
Installs: 24
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 1
Type:silverstripe-module
Requires
- silverstripe/framework: ~3.1
This package is not auto-updated.
Last update: 2020-06-12 19:39:35 UTC
README
A Silverstripe Link Field:
- 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