Version 1
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestFormStateValuesCleanAdvancedForm.php
1 <?php
2
3 namespace Drupal\form_test\Form;
4
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Form builder for \Drupal\Core\Form\FormState::cleanValues() test.
10  */
11 class FormTestFormStateValuesCleanAdvancedForm extends FormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function getFormId() {
17     return 'form_test_form_state_clean_values_advanced_form';
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   public function buildForm(array $form, FormStateInterface $form_state) {
24     // Build an example form containing a managed file and a submit form element.
25     $form['image'] = [
26       '#type' => 'managed_file',
27       '#title' => t('Image'),
28       '#upload_location' => 'public://',
29       '#default_value' => 0,
30     ];
31     $form['submit'] = [
32       '#type' => 'submit',
33       '#value' => t('Submit'),
34     ];
35     return $form;
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function submitForm(array &$form, FormStateInterface $form_state) {
42     $form_state->cleanValues();
43     print t('You WIN!');
44     exit;
45   }
46
47 }