Skip to content

PreviewableFieldInterface

Type
Interface
Namespace
craft\base
Extends
craft\base\FieldInterface
Implemented by
craft\base\InlineEditableFieldInterface, craft\fields\BaseOptionsField, craft\fields\Checkboxes, craft\fields\Dropdown, craft\fields\MultiSelect, craft\fields\RadioButtons
Since
3.0.0

PreviewableFieldInterface defines the common interface to be implemented by field classes that wish to be previewable in element table and card views.

View source

Public Methods

MethodDescription
afterDelete()Performs actions after a component is deleted.
afterElementDelete()Performs actions after the element has been deleted.
afterElementDeleteForSite()Performs actions after the element has been deleted.
afterElementPropagate()Performs actions after the element has been fully saved and propagated to other sites.
afterElementRestore()Performs actions after the element has been restored.
afterElementSave()Performs actions after the element has been saved.
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.
beforeElementDelete()Performs actions before an element is deleted.
beforeElementDeleteForSite()Performs actions before an element is deleted for a site.
beforeElementRestore()Performs actions before an element is restored.
beforeElementSave()Performs actions before an element is saved.
beforeSave()Performs actions before a component is saved.
copyValue()Copies the field’s value from one element to another.
dbType()Returns the DB data type(s) that this field will store within the elements_sites.content column.
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.
get()Returns a component by its ID.
getContentGqlMutationArgumentType()Returns the GraphQL type to be used as an argument in mutations for this field type.
getContentGqlQueryArgumentType()Returns the GraphQL type to be used as an argument in queries for this field type.
getContentGqlType()Returns the GraphQL type to be used for this field type.
getElementConditionRuleType()Returns the element condition rule class that should be used for this field.
getElementValidationRules()Returns the validation rules for an element with this field.
getId()Returns the ID of the component, which should be used as the value of hidden inputs.
getInputHtml()Returns the field’s input HTML.
getInputId()Returns the input’s ID, which the <label>’s for attribute should reference.
getIsNew()Returns whether the component is new (unsaved).
getIsTranslatable()Returns whether the field should be shown as translatable in the UI.
getLabelId()Returns the input’s label ID.
getOrientation()Returns the orientation the field should use (ltr or rtl).
getPreviewHtml()Returns the HTML that should be shown for this field in table and card views.
getSearchKeywords()Returns the search keywords that should be associated with this field.
getSettings()Returns an array of the component’s settings.
getSettingsHtml()Returns the component’s settings HTML.
getStaticHtml()Returns a static (non-editable) version of the field’s input HTML.
getStatus()Returns the status of the field for a given element.
getTranslationDescription()Returns the description of this field’s translation support.
getTranslationKey()Returns the field’s translation key, based on a given element.
getUiLabel()Returns what the component should be called within the control panel.
getValueSql()Returns a SQL expression which extracts the field’s value from the elements_sites.content column.
icon()Returns the field type’s SVG icon.
includeInGqlSchema()Returns whether the field should be included in the given GraphQL schema.
instance()Returns static class instance, which can be used to obtain meta information.
isMultiInstance()Returns whether the field can be included multiple times within a field layout.
isRequirable()Returns whether the field can be marked as required.
isSelectable()Returns whether the component should be selectable in component Type selects.
isValueEmpty()Returns whether the given value should be considered “empty” to a validator.
modifyElementIndexQuery()Modifies an element index query.
normalizeValue()Normalizes the field’s value for use.
normalizeValueFromRequest()Normalizes a posted field value for use.
phpType()Returns the PHPDoc type this field’s values will have.
queryCondition()Returns a query builder-compatible condition for the given field instances, for a user-provided param value.
serializeValue()Prepares the field’s value to be stored somewhere, like the content table.
setIsFresh()Sets whether the field is fresh.
settingsAttributes()Returns the list of settings attribute names.
supportedTranslationMethods()Returns which translation methods the field supports.
toArray()Converts the object into an array.
useFieldset()Returns whether the field should use a <fieldset> + <legend> instead of a <div> + <label>.

getPreviewHtml()

Since
5.0.0

Returns the HTML that should be shown for this field in table and card views.

View source

Arguments

Returns

string – The HTML that should be shown for this field in table and card views