diff --git a/core/lib/Drupal/Core/Render/Element/Email.php b/core/lib/Drupal/Core/Render/Element/Email.php index dce2a344c4953a45737654dc4e8fa6141534b8e4..84bb35265c34215facefe4c03f5f2430ec562b47 100644 --- a/core/lib/Drupal/Core/Render/Element/Email.php +++ b/core/lib/Drupal/Core/Render/Element/Email.php @@ -11,12 +11,14 @@ * Properties: * - #default_value: An RFC-compliant email address. * - #size: The size of the input element in characters. + * - #pattern: A string for the native HTML5 pattern attribute. * * Example usage: * @code * $form['email'] = array( * '#type' => 'email', * '#title' => $this->t('Email'), + * '#pattern' => '*@example.com', * ); * @end * diff --git a/core/lib/Drupal/Core/Render/Element/Password.php b/core/lib/Drupal/Core/Render/Element/Password.php index 4ba2058397dc01f6c455749c1a8c6b6daa6872ad..c40bb4c25abafd6a4ac8a44b2355814b26d78cc9 100644 --- a/core/lib/Drupal/Core/Render/Element/Password.php +++ b/core/lib/Drupal/Core/Render/Element/Password.php @@ -10,6 +10,7 @@ * * Properties: * - #size: The size of the input element in characters. + * - #pattern: A string for the native HTML5 pattern attribute. * * Usage example: * @code @@ -17,6 +18,7 @@ * '#type' => 'password', * '#title' => $this->t('Password'), * '#size' => 25, + * '#pattern' => '[01]+', * ); * @endcode * diff --git a/core/lib/Drupal/Core/Render/Element/Tel.php b/core/lib/Drupal/Core/Render/Element/Tel.php index 9289a1d028ce711b50af325ec196b37504a27bf1..041f68a6549d6e081ab094b6ba31d76f9d9ed505 100644 --- a/core/lib/Drupal/Core/Render/Element/Tel.php +++ b/core/lib/Drupal/Core/Render/Element/Tel.php @@ -12,12 +12,14 @@ * * Properties: * - #size: The size of the input element in characters. + * - #pattern: A string for the native HTML5 pattern attribute. * * Usage example: * @code * $form['phone'] = array( * '#type' => 'tel', * '#title' => $this->t('Phone'), + * '#pattern' => '[^\d]*', * ); * @endcode * diff --git a/core/lib/Drupal/Core/Render/Element/Textfield.php b/core/lib/Drupal/Core/Render/Element/Textfield.php index 0bdc294a096b8ded27c23d9ce3d7ed06f2316c5f..763646b7a475d403ed83b14b5021d0646628d8dc 100644 --- a/core/lib/Drupal/Core/Render/Element/Textfield.php +++ b/core/lib/Drupal/Core/Render/Element/Textfield.php @@ -15,6 +15,7 @@ * autocomplete JavaScript library. * - #autocomplete_route_parameters: An array of parameters to be used in * conjunction with the route name. + * - #pattern: A string for the native HTML5 pattern attribute. * * Usage example: * @code @@ -24,7 +25,8 @@ * '#default_value' => $node->title, * '#size' => 60, * '#maxlength' => 128, - * '#required' => TRUE, + * '#pattern' => 'some-prefix-[a-z]+', + * '#required' => TRUE, * ); * @endcode * diff --git a/core/lib/Drupal/Core/Render/Element/Url.php b/core/lib/Drupal/Core/Render/Element/Url.php index c3574b095ef089d1b9c5b14f58b179555b5934bb..66e2141a894ba2ddd3f60beda59a5d73bdc69443 100644 --- a/core/lib/Drupal/Core/Render/Element/Url.php +++ b/core/lib/Drupal/Core/Render/Element/Url.php @@ -12,6 +12,7 @@ * Properties: * - #default_value: A valid URL string. * - #size: The size of the input element in characters. + * - #pattern: A string for the native HTML5 pattern attribute. * * Usage example: * @code @@ -19,6 +20,7 @@ * '#type' => 'url', * '#title' => $this->t('Home Page'), * '#size' => 30, + * '#pattern' => '*.example.com', * ... * ); * @endcode