Version 1
[yaffs-website] / web / core / modules / block / tests / modules / block_test / src / Form / FavoriteAnimalTestForm.php
diff --git a/web/core/modules/block/tests/modules/block_test/src/Form/FavoriteAnimalTestForm.php b/web/core/modules/block/tests/modules/block_test/src/Form/FavoriteAnimalTestForm.php
new file mode 100644 (file)
index 0000000..9aa74c6
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace Drupal\block_test\Form;
+
+use Drupal\Core\Form\FormBase;
+use Drupal\Core\Form\FormStateInterface;
+
+class FavoriteAnimalTestForm extends FormBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'block_test_form_favorite_animal_test';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $form['favorite_animal'] = [
+      '#type' => 'textfield',
+      '#title' => $this->t('Your favorite animal.')
+    ];
+
+    $form['submit_animal'] = [
+      '#type' => 'submit',
+      '#value' => $this->t('Submit your chosen animal'),
+    ];
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    drupal_set_message($this->t('Your favorite animal is: @favorite_animal', ['@favorite_animal' => $form['favorite_animal']['#value']]));
+  }
+
+}