Skip to content

SavableComponentInterface ​

Type
Interface
Namespace
craft\base
Extends
craft\base\ConfigurableComponentInterface
Implemented by
craft\base\Field, craft\base\FieldInterface, craft\base\Fs, craft\base\FsInterface, craft\base\SavableComponent, craft\base\Widget, craft\base\WidgetInterface, craft\fields\Addresses, craft\fields\Assets, craft\fields\BaseOptionsField, craft\fields\BaseRelationField, craft\fields\Categories, craft\fields\Checkboxes, craft\fields\Color, craft\fields\Country, craft\fields\Date, craft\fields\Dropdown, craft\fields\Email, craft\fields\Entries, craft\fields\Icon, craft\fields\Lightswitch, craft\fields\Link, craft\fields\Matrix, craft\fields\MissingField, craft\fields\Money, craft\fields\MultiSelect, craft\fields\Number, craft\fields\PlainText, craft\fields\RadioButtons, craft\fields\Range, craft\fields\Table, craft\fields\Tags, craft\fields\Time, craft\fields\Users, craft\fs\Local, craft\fs\MissingFs, craft\fs\Temp, 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

SavableComponentInterface defines the common interface to be implemented by savable Craft component classes.

A class implementing this interface should extend craft\base\Model and also use craft\base\SavableComponentTrait.

View source

Public Methods ​

MethodDescription
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.
getIsNew()Returns whether the component is new (unsaved).
getSettings()Returns an array of the component’s settings.
getSettingsHtml()Returns the component’s settings HTML.
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.
settingsAttributes()Returns the list of settings attribute names.
toArray()Converts the object into an array.

afterDelete() ​

Performs actions after a component is deleted.

View source

afterSave() ​

Performs actions after a component is saved.

View source

Arguments ​

  • $isNew (boolean) – Whether the component is brand new

beforeApplyDelete() ​

Since
3.1.0

Performs actions before a component delete is applied to the database.

View source

beforeDelete() ​

Performs actions before a component is deleted.

View source

Returns ​

boolean – Whether the component should be deleted

beforeSave() ​

Performs actions before a component is saved.

View source

Arguments ​

  • $isNew (boolean) – Whether the component is brand new

Returns ​

boolean – Whether the component should be saved

getIsNew() ​

Returns whether the component is new (unsaved).

View source

Returns ​

boolean – Whether the component is new