3 namespace Drupal\block_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
8 class FavoriteAnimalTestForm extends FormBase {
13 public function getFormId() {
14 return 'block_test_form_favorite_animal_test';
20 public function buildForm(array $form, FormStateInterface $form_state) {
21 $form['favorite_animal'] = [
22 '#type' => 'textfield',
23 '#title' => $this->t('Your favorite animal.')
26 $form['submit_animal'] = [
28 '#value' => $this->t('Submit your chosen animal'),
37 public function submitForm(array &$form, FormStateInterface $form_state) {
38 drupal_set_message($this->t('Your favorite animal is: @favorite_animal', ['@favorite_animal' => $form['favorite_animal']['#value']]));