acquia_dam-1.0.0-rc1/src/Plugin/Field/FieldWidget/AssetItemWidget.php
src/Plugin/Field/FieldWidget/AssetItemWidget.php
<?php declare(strict_types=1); namespace Drupal\acquia_dam\Plugin\Field\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; /** * Field widget for the asset item field type. * * @FieldWidget( * id = "acquia_dam_asset_item", * label = @Translation("Asset ID"), * field_types = {"acquia_dam_asset"}, * ) */ final class AssetItemWidget extends WidgetBase { /** * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state): array { $original_element = $element; $element['asset_id'] = [ '#title' => $this->t('Asset ID'), '#type' => 'textfield', '#disabled' => TRUE, '#default_value' => $items[$delta]->asset_id ?? NULL, '#attributes' => ['class' => ['js-text-full', 'text-full']], ] + $original_element; $element['version_id'] = [ '#title' => $this->t('Version ID'), '#type' => 'textfield', '#disabled' => TRUE, '#default_value' => $items[$delta]->version_id ?? NULL, '#attributes' => ['class' => ['js-text-full', 'text-full']], ] + $original_element; $element['external_id'] = [ '#title' => $this->t('External ID'), '#type' => 'textfield', '#disabled' => TRUE, '#default_value' => $items[$delta]->external_id ?? NULL, '#attributes' => ['class' => ['js-text-full', 'text-full']], ] + $original_element; return $element; } }