class FormTestPatternForm
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php \Drupal\form_test\Form\FormTestPatternForm
- 10 core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php \Drupal\form_test\Form\FormTestPatternForm
- 8.9.x core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php \Drupal\form_test\Form\FormTestPatternForm
Builds a simple form using the FAPI #pattern property.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase implements \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\form_test\Form\FormTestPatternForm extends \Drupal\Core\Form\FormBase
Expanded class hierarchy of FormTestPatternForm
1 string reference to 'FormTestPatternForm'
- form_test.routing.yml in core/
modules/ system/ tests/ modules/ form_test/ form_test.routing.yml - core/modules/system/tests/modules/form_test/form_test.routing.yml
File
-
core/
modules/ system/ tests/ modules/ form_test/ src/ Form/ FormTestPatternForm.php, line 13
Namespace
Drupal\form_test\FormView source
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) {
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.