Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestPatternForm.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  * Builds a simple form using the FAPI #pattern property.
10  */
11 class FormTestPatternForm extends FormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function getFormId() {
17     return 'form_test_pattern_form';
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   public function buildForm(array $form, FormStateInterface $form_state) {
24     $form['textfield'] = [
25       '#type' => 'textfield',
26       '#title' => 'One digit followed by lowercase letters',
27       '#pattern' => '[0-9][a-z]+',
28     ];
29     $form['tel'] = [
30       '#type' => 'tel',
31       '#title' => 'Everything except numbers',
32       '#pattern' => '[^\d]*',
33     ];
34     $form['password'] = [
35       '#type' => 'password',
36       '#title' => 'Password',
37       '#pattern' => '[01]+',
38     ];
39     $form['url'] = [
40       '#type' => 'url',
41       '#title' => 'Client side validation',
42       '#decription' => 'Just client side validation, using the #pattern attribute.',
43       '#attributes' => [
44         'pattern' => '.*foo.*',
45       ],
46       '#pattern' => 'ignored',
47     ];
48     $form['submit'] = [
49       '#type' => 'submit',
50       '#value' => 'Submit',
51     ];
52     return $form;
53   }
54
55   /**
56    * {@inheritdoc}
57    */
58   public function submitForm(array &$form, FormStateInterface $form_state) {
59   }
60
61 }