clesson-de / silverstripe-hints
A Silverstripe CMS form field that displays a collapsible alert hint in the CMS edit form.
Package info
github.com/clesson-de/silverstripe-hints
Type:silverstripe-vendormodule
pkg:composer/clesson-de/silverstripe-hints
Requires
- php: ^8.1
- silverstripe/admin: ^3
- silverstripe/framework: ^6
This package is auto-updated.
Last update: 2026-05-08 09:02:17 UTC
README
A Silverstripe CMS module providing the HintField form field — a collapsible alert panel for the CMS edit form.
Requirements
- PHP ^8.1
- Silverstripe Framework ^6
- Silverstripe Admin ^3
Installation
composer require clesson-de/silverstripe-hints
After installation, run:
composer vendor-expose
Usage
use Clesson\Silverstripe\Hints\Constants\HintType; use Clesson\Silverstripe\Hints\Forms\HintField; // Expanded info hint (default) $fields->addFieldToTab('Root.Main', HintField::create( 'MyHint', 'Important note', '<p>Please read this carefully before saving.</p>' )); // Collapsed warning hint $fields->addFieldToTab('Root.Main', HintField::create( 'MyWarning', 'Warning', '<p>This action cannot be undone.</p>' )->setType(HintType::WARNING)->setCollapsed(true));
Available types
| Constant | Visual style |
|---|---|
HintType::INFO |
Blue |
HintType::WARNING |
Yellow |
HintType::DANGER |
Red |
HintType::SUCCESS |
Green |
API
| Method | Description |
|---|---|
setContent(string $html) |
Sets the HTML body content. |
setType(string $type) |
Sets the alert type (use HintType constants). |
setCollapsed(bool $flag) |
Sets whether the alert starts collapsed. |
Frontend Assets
The module ships with pre-compiled CSS in client/admin/dist/. The CSS is automatically loaded by the field when it is rendered.
If you want to modify the styles, recompile them:
Prerequisites
nvm use 20 npm install
Build
npm run build
This compiles client/admin/src/scss/main.scss → client/admin/dist/bundle.css.
License
BSD 3-Clause — see LICENSE.