You are here

protected function ButtonFieldImage::elementProperties in Button Field 8

Same name in this branch
  1. 8 src/Plugin/Field/FieldFormatter/ButtonFieldImage.php \Drupal\button_field\Plugin\Field\FieldFormatter\ButtonFieldImage::elementProperties()
  2. 8 src/Plugin/Field/FieldWidget/ButtonFieldImage.php \Drupal\button_field\Plugin\Field\FieldWidget\ButtonFieldImage::elementProperties()

Retrieves the properties for the current widget's element.

Return value

array Properties for the widget element.

Overrides ButtonFieldBase::elementProperties

File

src/Plugin/Field/FieldWidget/ButtonFieldImage.php, line 81
Contains Drupal\button_field\Plugin\Field\FieldWidget\ButtonFieldImage.

Class

ButtonFieldImage
Plugin implementation of the 'button html' widget.

Namespace

Drupal\button_field\Plugin\Field\FieldWidget

Code

protected function elementProperties() {
  return array(
    '#type' => 'image_button',
    '#src' => $this
      ->getSetting('image_path'),
    '#attributes' => array(
      'alt' => $this
        ->getSetting('alt_text') ?: $this->fieldDefinition
        ->getLabel(),
      'title' => $this
        ->getSetting('title_text'),
    ),
  );
}