FormTestFormStateValuesCleanAdvancedForm.php

Same filename in other branches
  1. 8.9.x core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
  2. 10 core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
  3. 11.x core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php

Namespace

Drupal\form_test\Form

File

core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php

View source
<?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.
 *
 * @internal
 */
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;
    }

}

Classes

Title Deprecated Summary
FormTestFormStateValuesCleanAdvancedForm Form builder for \Drupal\Core\Form\FormState::cleanValues() test.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.