Drupal 8  8.0.2
ImageWidget Class Reference
Inheritance diagram for ImageWidget:

Public Member Functions

 settingsForm (array $form, FormStateInterface $form_state)
 
 settingsSummary ()
 
 formElement (FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
 
- Public Member Functions inherited from FileWidget
 __construct ($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, ElementInfoManagerInterface $element_info)
 
 settingsForm (array $form, FormStateInterface $form_state)
 
 settingsSummary ()
 
 formElement (FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
 
 massageFormValues (array $values, array $form, FormStateInterface $form_state)
 
 flagErrors (FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state)
 
- Public Member Functions inherited from WidgetBase
 __construct ($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings)
 
 form (FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta=NULL)
 
 extractFormValues (FieldItemListInterface $items, array $form, FormStateInterface $form_state)
 
 settingsForm (array $form, FormStateInterface $form_state)
 
 settingsSummary ()
 
 errorElement (array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state)
 
 massageFormValues (array $values, array $form, FormStateInterface $form_state)
 
- Public Member Functions inherited from PluginSettingsBase
 getSettings ()
 
 getSetting ($key)
 
 setSettings (array $settings)
 
 setSetting ($key, $value)
 
 getThirdPartySettings ($module=NULL)
 
 getThirdPartySetting ($module, $key, $default=NULL)
 
 setThirdPartySetting ($module, $key, $value)
 
 unsetThirdPartySetting ($module, $key)
 
 getThirdPartyProviders ()
 
 calculateDependencies ()
 
 onDependencyRemoval (array $dependencies)
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 
- Public Member Functions inherited from WidgetBaseInterface
 flagErrors (FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state)
 

Static Public Member Functions

static defaultSettings ()
 
static process ($element, FormStateInterface $form_state, $form)
 
static validateRequiredFields ($element, FormStateInterface $form_state)
 
- Static Public Member Functions inherited from FileWidget
static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static defaultSettings ()
 
static value ($element, $input=FALSE, FormStateInterface $form_state)
 
static validateMultipleCount ($element, FormStateInterface $form_state, $form)
 
static process ($element, FormStateInterface $form_state, $form)
 
static processMultiple ($element, FormStateInterface $form_state, $form)
 
static submit ($form, FormStateInterface $form_state)
 
- Static Public Member Functions inherited from WidgetBase
static afterBuild (array $element, FormStateInterface $form_state)
 
static addMoreSubmit (array $form, FormStateInterface $form_state)
 
static addMoreAjax (array $form, FormStateInterface $form_state)
 
static getWidgetState (array $parents, $field_name, FormStateInterface $form_state)
 
static setWidgetState (array $parents, $field_name, FormStateInterface $form_state, array $field_state)
 
static isApplicable (FieldDefinitionInterface $field_definition)
 
- Static Public Member Functions inherited from PluginSettingsBase
static defaultSettings ()
 

Protected Member Functions

 formMultipleElements (FieldItemListInterface $items, array &$form, FormStateInterface $form_state)
 
- Protected Member Functions inherited from FileWidget
 formMultipleElements (FieldItemListInterface $items, array &$form, FormStateInterface $form_state)
 
- Protected Member Functions inherited from WidgetBase
 formMultipleElements (FieldItemListInterface $items, array &$form, FormStateInterface $form_state)
 
 formSingleElement (FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state)
 
 getFieldSettings ()
 
 getFieldSetting ($setting_name)
 
 handlesMultipleValues ()
 
 isDefaultValueWidget (FormStateInterface $form_state)
 
- Protected Member Functions inherited from PluginSettingsBase
 mergeDefaults ()
 

Additional Inherited Members

- Static Protected Member Functions inherited from FileWidget
static getDescriptionFromElement ($element)
 
- Static Protected Member Functions inherited from WidgetBase
static getWidgetStateParents (array $parents, $field_name)
 
- Protected Attributes inherited from WidgetBase
 $fieldDefinition
 
 $settings
 
- Protected Attributes inherited from PluginSettingsBase
 $settings = array()
 
 $thirdPartySettings = array()
 
 $defaultSettingsMerged = FALSE
 

Detailed Description

Plugin implementation of the 'image_image' widget.

( id = "image_image", label = ("Image"), field_types = { "image" } )

Member Function Documentation

static defaultSettings ( )
static

{Defines the default settings for this plugin.

Returns
array A list of default settings, keyed by the setting name.
}

Implements PluginSettingsInterface.

formElement ( FieldItemListInterface  $items,
  $delta,
array  $element,
array &  $form,
FormStateInterface  $form_state 
)

{Returns the form for a single field widget.Field widget form elements should be based on the passed-in $element, which contains the base form element properties derived from the field configuration.The BaseWidget methods will set the weight, field name and delta values for each form element. If there are multiple values for this field, the formElement() method will be called as many times as needed.Other modules may alter the form element provided by this function using hook_field_widget_form_alter() or hook_field_widget_WIDGET_TYPE_form_alter().The FAPI element callbacks (such as #process, #element_validate, #value_callback, etc.) used by the widget do not have access to the original $field_definition passed to the widget's constructor. Therefore, if any information is needed from that definition by those callbacks, the widget implementing this method, or a hook_field_widget[_WIDGET_TYPE]_form_alter() implementation, must extract the needed properties from the field definition and set them as ad-hoc $element['#custom'] properties, for later use by its element callbacks.

Parameters
\Drupal\Core\Field\FieldItemListInterface$itemsArray of default values for this field.
int$deltaThe order of this item in the array of sub-elements (0, 1, 2, etc.).
array$elementA form element array containing basic properties for the widget:
  • #field_parents: The 'parents' space for the field in the form. Most widgets can simply overlook this property. This identifies the location where the field values are placed within $form_state->getValues(), and is used to access processing information for the field through the getWidgetState() and setWidgetState() methods.
  • #title: The sanitized element label for the field, ready for output.
  • #description: The sanitized element description for the field, ready for output.
  • #required: A Boolean indicating whether the element value is required; for required multiple value fields, only the first widget's values are required.
  • #delta: The order of this item in the array of sub-elements; see $delta above.
array$formThe form structure where widgets are being attached to. This might be a full form structure, or a sub-element of a larger form.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
Returns
array The form elements for a single widget for this field.
See Also
hook_field_widget_form_alter()
hook_field_widget_WIDGET_TYPE_form_alter()
}

Implements WidgetInterface.

References Drupal\entityManager(), WidgetBase\getFieldSettings(), and PluginSettingsBase\getSetting().

Here is the call graph for this function:

formMultipleElements ( FieldItemListInterface  $items,
array &  $form,
FormStateInterface  $form_state 
)
protected

Overrides ::formMultipleElements().

Special handling for draggable multiple widgets and 'add more' button.

References Drupal\service().

Here is the call graph for this function:

static process (   $element,
FormStateInterface  $form_state,
  $form 
)
static

Form API callback: Processes a image_image field element.

Expands the image_image type to include the alt and title fields.

This method is assigned as a process callback in formElement() method.

References Entity\load(), Drupal\service(), and t().

Here is the call graph for this function:

settingsForm ( array  $form,
FormStateInterface  $form_state 
)

{Returns a form to configure settings for the widget.Invoked from to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.

Parameters
array$formThe form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the form.
Returns
array The form definition for the widget settings.
}

Implements WidgetInterface.

References PluginSettingsBase\getSetting(), and t().

Here is the call graph for this function:

settingsSummary ( )

{Returns a short summary for the current widget settings.If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Returns
array A short summary of the widget settings.
}

Implements WidgetInterface.

References PluginSettingsBase\getSetting(), and t().

Here is the call graph for this function:

static validateRequiredFields (   $element,
FormStateInterface  $form_state 
)
static

Validate callback for alt and title field, if the user wants them required.

This is separated in a validate function instead of a #required flag to avoid being validated on the process callback.

References FormStateInterface\getTriggeringElement(), FormStateInterface\getUserInput(), NestedArray\getValue(), and FormStateInterface\setLimitValidationErrors().

Here is the call graph for this function:


The documentation for this class was generated from the following file: