Security update for permissions_by_term
[yaffs-website] / vendor / drupal / drupal-extension / fixtures / drupal8 / modules / behat_test / src / Plugin / Field / FieldWidget / AddressFieldWidget.php
diff --git a/vendor/drupal/drupal-extension/fixtures/drupal8/modules/behat_test/src/Plugin/Field/FieldWidget/AddressFieldWidget.php b/vendor/drupal/drupal-extension/fixtures/drupal8/modules/behat_test/src/Plugin/Field/FieldWidget/AddressFieldWidget.php
new file mode 100644 (file)
index 0000000..b780f57
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\behat_test\Plugin\field\widget\AddressFieldWidget.
+ */
+
+namespace Drupal\behat_test\Plugin\Field\FieldWidget;
+
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\WidgetBase;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Plugin implementation of the 'behat_test_address_field' widget.
+ *
+ * @FieldWidget(
+ *   id = "behat_test_address_field_default",
+ *   label = @Translation("Address field"),
+ *   module = "behat_test",
+ *   field_types = {
+ *     "behat_test_address_field"
+ *   }
+ * )
+ */
+class AddressFieldWidget extends WidgetBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
+    // Set up the form element.
+    $element += ['#type' => 'details', '#open' => TRUE];
+
+    // Add in the textfields.
+    $columns = [
+      'country' => t('Country'),
+      'locality' => t('Locality'),
+      'thoroughfare' => t('Thoroughfare'),
+      'postal_code' => t('Postal code'),
+    ];
+    foreach ($columns as $key => $title) {
+      $element[$key] = [
+        '#type' => 'textfield',
+        '#title' => $title,
+        '#default_value' => isset($items[$delta]->$key) ? $items[$delta]->$key : '',
+      ];
+    }
+
+    return $element;
+  }
+
+}