WidgetInterface ​
- Type
- Interface
- Namespace
- craft\base
- Extends
- craft\base\SavableComponentInterface
- Implemented by
- craft\base\Widget, craft\widgets\CraftSupport, craft\widgets\Feed, craft\widgets\MissingWidget, craft\widgets\MyDrafts, craft\widgets\NewUsers, craft\widgets\QuickPost, craft\widgets\RecentEntries, craft\widgets\Updates
- Since
- 3.0.0
WidgetInterface defines the common interface to be implemented by dashboard widget classes.
A class implementing this interface should also use craft\base\SavableComponentTrait and craft\base\WidgetTrait.
Public Methods ​
| Method | Description |
|---|---|
| afterDelete() | Performs actions after a component is deleted. |
| afterSave() | Performs actions after a component is saved. |
| beforeApplyDelete() | Performs actions before a component delete is applied to the database. |
| beforeDelete() | Performs actions before a component is deleted. |
| beforeSave() | Performs actions before a component is saved. |
| displayName() | Returns the display name of this class. |
| extraFields() | Returns the list of additional fields that can be returned by toArray() in addition to those listed in fields(). |
| fields() | Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. |
| getBodyHtml() | Returns the widget's body HTML. |
| getIsNew() | Returns whether the component is new (unsaved). |
| getReadOnlySettingsHtml() | Returns a read-only version of the component’s settings HTML. |
| getSettings() | Returns an array of the component’s settings. |
| getSettingsHtml() | Returns the component’s settings HTML. |
| getSubtitle() | Returns the widget’s subtitle. |
| getTitle() | Returns the widget’s title. |
| icon() | Returns the widget’s SVG icon, if it has one. |
| instance() | Returns static class instance, which can be used to obtain meta information. |
| isSelectable() | Returns whether the component should be selectable in component Type selects. |
| maxColspan() | Returns the widget’s maximum colspan. |
| settingsAttributes() | Returns the list of settings attribute names. |
| toArray() | Converts the object into an array. |
getBodyHtml() ​
Returns the widget's body HTML.
Returns ​
string, null – The widget’s body HTML, or null if the widget should not be visible. (If you don’t want the widget to be selectable in the first place, use isSelectable().)
getSubtitle() ​
- Since
- 3.4.0
Returns the widget’s subtitle.
Returns ​
string, null – The widget’s subtitle
getTitle() ​
Returns the widget’s title.
Returns ​
string, null – The widget’s title.
icon() ​
- Since
- 3.2.0
Returns the widget’s SVG icon, if it has one.
The returned icon can be a system icon’s name (e.g. 'whiskey-glass-ice'), the path to an SVG file, or raw SVG markup.
System icons can be found in src/icons/solid/.
Returns ​
maxColspan() ​
Returns the widget’s maximum colspan.
Returns ​
integer, null – The widget’s maximum colspan, if it has one