xddesigners/iconselectfield

Adds a configurable icon select field

Installs: 19

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

dev-main 2021-03-04 14:58 UTC

This package is not auto-updated.

Last update: 2021-10-15 15:45:46 UTC


README

Add a icon select field to the Silverstripe CMS.

Installation

composer require xddesigners/iconselectfield

Usage

Add a icon field to your db. This field will automaticly scaffold a IconSelectField.

class YourClass extends DataObject
{
  private static $db = [
    'Icon' => 'Icon'
  ];

  public function getCMSFields()
  {
    $fields = parent::getCMSFields();
    $fields->addFieldsToTab('Root.Main', [
      // this field is automaticly scaffolded
      IconSelectField::create('Icon', 'Icon')
    ]);

    $fields;
  }
}

In your template you can now access the Icon property and this will be replaced by the selected icon.

$Icon

You can confugure the icons you want to use trough a yml config.

---
Name: vivabasicIcons
---
XD\IconSelectField\Forms\IconSelectField:
  fonts_include:
  # add your own link to a font awesome version your using
    - '<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.12.1/css/all.css" crossorigin="anonymous">'
  icons:
    system:
      arrow-right: 'fas fa-arrow-right'
      arrow-left: 'fas fa-arrow-left'
      custom-icon: '<svg />' # you can also configure custom svg icons