PHP code example of restruct / silverstripe-namedlinkfield

1. Go to this page and download the library: Download restruct/silverstripe-namedlinkfield library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

restruct / silverstripe-namedlinkfield example snippets


use Restruct\SilverStripe\ORM\FieldType\NamedLinkField;

private static $db = [
    'PrimaryButton' => NamedLinkField::class,
];

use Restruct\SilverStripe\Forms\NamedLinkFormField;

public function getCMSFields()
{
    $fields = parent::getCMSFields();

    $fields->insertBefore('Content', NamedLinkFormField::create('PrimaryButton', 'Primary button'));

    return $fields;
}