X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fmodules%2Fform_test%2Fsrc%2FForm%2FFormTestLabelForm.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fmodules%2Fform_test%2Fsrc%2FForm%2FFormTestLabelForm.php;h=a22bf7d092108d232c221294660a4a66a4852b55;hp=88de2300898a59bff9dbbe1a2192276ccfe3fe4a;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php b/web/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php index 88de23008..a22bf7d09 100644 --- a/web/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php +++ b/web/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php @@ -12,6 +12,40 @@ use Drupal\Core\Form\FormStateInterface; */ class FormTestLabelForm extends FormBase { + /** + * An array of elements that render a title. + * + * @var array + */ + public static $typesWithTitle = [ + 'checkbox', + 'checkboxes', + 'color', + 'date', + 'datelist', + 'datetime', + 'details', + 'email', + 'fieldset', + 'file', + 'item', + 'managed_file', + 'number', + 'password', + 'password_confirm', + 'radio', + 'radios', + 'range', + 'search', + 'select', + 'tel', + 'textarea', + 'textfield', + 'text_format', + 'url', + 'weight', + ]; + /** * {@inheritdoc} */ @@ -125,6 +159,21 @@ class FormTestLabelForm extends FormBase { ], '#required' => TRUE, ]; + + foreach (static::$typesWithTitle as $type) { + $form['form_' . $type . '_title_no_xss'] = [ + '#type' => $type, + '#title' => "$type is XSS filtered!", + ]; + // Add keys that are required for some elements to be processed correctly. + if (in_array($type, ['checkboxes', 'radios'], TRUE)) { + $form['form_' . $type . '_title_no_xss']['#options'] = []; + } + if ($type === 'datetime') { + $form['form_' . $type . '_title_no_xss']['#default_value'] = NULL; + } + } + return $form; }