3 namespace Drupal\entity_test\Plugin\Field\FieldWidget;
5 use Drupal\Core\Field\FieldItemListInterface;
6 use Drupal\Core\Field\WidgetBase;
7 use Drupal\Core\Form\FormStateInterface;
10 * Plugin implementation of the 'shape_only_color_editable_widget' widget.
13 * id = "shape_only_color_editable_widget",
14 * label = @Translation("Shape widget with only color editable property"),
20 class ShapeOnlyColorEditableWidget extends WidgetBase {
25 public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
28 '#value' => $items[$delta]->shape
32 '#type' => 'textfield',
33 '#default_value' => isset($items[$delta]->color) ? $items[$delta]->color : NULL,