Skip to content
Snippets Groups Projects

Issue #3500182 - Add new examples

1 file
+ 32
0
Compare changes
  • Side-by-side
  • Inline
@@ -46,6 +46,38 @@ class SimpleForm extends FormBase {
@@ -46,6 +46,38 @@ class SimpleForm extends FormBase {
'#required' => TRUE,
'#required' => TRUE,
];
];
 
$form['mail'] = [
 
'#type' => 'textfield',
 
'#title' => $this->t('Email'),
 
'#description' => $this->t('Email must be valid e-mail address.'),
 
'#validators' => ['email'],
 
'#required' => TRUE,
 
];
 
 
$form['range'] = [
 
'#type' => 'textfield',
 
'#title' => $this->t('Range'),
 
'#description' => $this->t('The value should be between 0 and 100.'),
 
'#validators' => ['rule' => 'range[0, 100]'],
 
'#required' => TRUE,
 
];
 
 
$form['ip'] = [
 
'#type' => 'textfield',
 
'#title' => $this->t('IP address'),
 
'#description' => $this->t('The value should be valid IP address. e.g. 127.0.0.1'),
 
'#validators' => ['ipv4'],
 
'#required' => TRUE,
 
];
 
 
$form['url'] = [
 
'#type' => 'textfield',
 
'#title' => $this->t('URL'),
 
'#description' => $this->t('The value should be valid absolute URL. e.g. http://example.com'),
 
'#validators' => ['url[absolute]'],
 
'#required' => TRUE,
 
];
 
// Group submit handlers in an actions element with a key of "actions" so
// Group submit handlers in an actions element with a key of "actions" so
// that it gets styled correctly, and so that other modules may add actions
// that it gets styled correctly, and so that other modules may add actions
// to the form. This is not required, but is convention.
// to the form. This is not required, but is convention.
Loading