Version 1
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestFormStateValuesCleanAdvancedForm.php
diff --git a/web/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php b/web/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
new file mode 100644 (file)
index 0000000..f910469
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+namespace Drupal\form_test\Form;
+
+use Drupal\Core\Form\FormBase;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Form builder for \Drupal\Core\Form\FormState::cleanValues() test.
+ */
+class FormTestFormStateValuesCleanAdvancedForm extends FormBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'form_test_form_state_clean_values_advanced_form';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    // Build an example form containing a managed file and a submit form element.
+    $form['image'] = [
+      '#type' => 'managed_file',
+      '#title' => t('Image'),
+      '#upload_location' => 'public://',
+      '#default_value' => 0,
+    ];
+    $form['submit'] = [
+      '#type' => 'submit',
+      '#value' => t('Submit'),
+    ];
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    $form_state->cleanValues();
+    print t('You WIN!');
+    exit;
+  }
+
+}