29b3b5f96134e12f10d34f932b604481fcd55a81
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestValidateRequiredNoTitleForm.php
1 <?php
2
3 namespace Drupal\form_test\Form;
4
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Form constructor to test the #required property without #title.
10  */
11 class FormTestValidateRequiredNoTitleForm extends FormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function getFormId() {
17     return 'form_test_validate_required_form_no_title';
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   public function buildForm(array $form, FormStateInterface $form_state) {
24     $form['textfield'] = [
25       '#type' => 'textfield',
26       '#required' => TRUE,
27     ];
28     $form['actions'] = ['#type' => 'actions'];
29     $form['actions']['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
30     return $form;
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function submitForm(array &$form, FormStateInterface $form_state) {
37     drupal_set_message('The form_test_validate_required_form_no_title form was submitted successfully.');
38   }
39
40 }