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.

View source (opens new window)

# 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() (opens new window) Returns the list of additional fields that can be returned by toArray() (opens new window) in addition to those listed in fields() (opens new window).
fields() (opens new window) Returns the list of fields that should be returned by default by toArray() (opens new window) when no specific fields are specified.
getBodyHtml() Returns the widget's body HTML.
getIsNew() Returns whether the component is new (unsaved).
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 path to the widget’s SVG icon, or the actual SVG contents.
instance() (opens new window) 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() (opens new window) Converts the object into an array.

# getBodyHtml()

Returns the widget's body HTML.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – 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.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The widget’s subtitle

# getTitle()

Returns the widget’s title.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The widget’s title.

# icon()

Since
3.2.0

Returns the path to the widget’s SVG icon, or the actual SVG contents.

View source (opens new window)

Returns

string (opens new window), null (opens new window)

# maxColspan()

Returns the widget’s maximum colspan.

View source (opens new window)

Returns

integer (opens new window), null (opens new window) – The widget’s maximum colspan, if it has one