WidgetBaseInterface
interface WidgetBaseInterface implements PluginSettingsInterface (View source)
Base interface definition for "Field widget" plugins.
This interface details base wrapping methods that most widget implementations will want to directly inherit from Drupal\Core\Field\WidgetBase. See Drupal\Core\Field\WidgetInterface for methods that will more likely be overridden in actual widget implementations.
Methods
Gets the definition of the plugin implementation.
Sets the value of a third-party setting.
Gets the value of a third-party setting.
Gets all third-party settings of a given module.
Unsets a third-party setting.
Gets the list of third parties that store information.
Defines the default settings for this plugin.
Returns the array of settings, including defaults for missing settings.
Returns the value of a setting, or its default value if absent.
Sets the value of a setting for the plugin.
Informs the plugin that some configuration it depends on will be deleted.
Creates a form element for a field.
Extracts field values from submitted form values.
Reports field-level validation errors against actual form elements.
Retrieves processing information about the widget from $form_state.
Stores processing information about the widget in $form_state.
Details
string
getPluginId()
Gets the plugin_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
$this
setThirdPartySetting(string $module, string $key, mixed $value)
Sets the value of a third-party setting.
mixed
getThirdPartySetting(string $module, string $key, mixed $default = NULL)
Gets the value of a third-party setting.
array
getThirdPartySettings(string $module)
Gets all third-party settings of a given module.
mixed
unsetThirdPartySetting(string $module, string $key)
Unsets a third-party setting.
array
getThirdPartyProviders()
Gets the list of third parties that store information.
static array
defaultSettings()
Defines the default settings for this plugin.
array
getSettings()
Returns the array of settings, including defaults for missing settings.
mixed
getSetting(string $key)
Returns the value of a setting, or its default value if absent.
$this
setSettings(array $settings)
Sets the settings for the plugin.
$this
setSetting(string $key, mixed $value)
Sets the value of a setting for the plugin.
bool
onDependencyRemoval(array $dependencies)
Informs the plugin that some configuration it depends on will be deleted.
This method allows plugins to keep their configuration up-to-date when a dependency calculated with ::calculateDependencies() is removed. For example, an entity view display contains a formatter having a setting pointing to an arbitrary config entity. When that config entity is deleted, this method is called by the view display to react to the dependency removal by updating its configuration.
This method must return TRUE if the removal event updated the plugin configuration or FALSE otherwise.
array
form(FieldItemListInterface $items, array $form, FormStateInterface $form_state, int $get_delta = NULL)
Creates a form element for a field.
If the entity associated with the form is new (i.e., $entity->isNew() is TRUE), the 'default value', if any, is pre-populated. Also allows other modules to alter the form element by implementing their own hooks.
extractFormValues(FieldItemListInterface $items, array $form, FormStateInterface $form_state)
Extracts field values from submitted form values.
flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state)
Reports field-level validation errors against actual form elements.
static array
getWidgetState(array $parents, string $field_name, FormStateInterface $form_state)
Retrieves processing information about the widget from $form_state.
This method is static so that it can be used in static Form API callbacks.
static
setWidgetState(array $parents, string $field_name, FormStateInterface $form_state, array $field_state)
Stores processing information about the widget in $form_state.
This method is static so that it can be used in static Form API #callbacks.