
| Current Path : /var/www/html1/bbp/web/core/modules/system/tests/modules/form_test/src/Form/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html1/bbp/web/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php |
<?php
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Builds a simple form using the FAPI #pattern property.
*
* @internal
*/
class FormTestPatternForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'form_test_pattern_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['textfield'] = [
'#type' => 'textfield',
'#title' => 'One digit followed by lowercase letters',
'#pattern' => '[0-9][a-z]+',
];
$form['tel'] = [
'#type' => 'tel',
'#title' => 'Everything except numbers',
'#pattern' => '[^\d]*',
];
$form['password'] = [
'#type' => 'password',
'#title' => 'Password',
'#pattern' => '[01]+',
];
$form['url'] = [
'#type' => 'url',
'#title' => 'Client side validation',
'#description' => 'Just client side validation, using the #pattern attribute.',
'#attributes' => [
'pattern' => '.*foo.*',
],
'#pattern' => 'ignored',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}