FormTestFormStateValuesCleanAdvancedForm.php in Drupal 9
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;
class FormTestFormStateValuesCleanAdvancedForm extends FormBase {
public function getFormId() {
return 'form_test_form_state_clean_values_advanced_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['image'] = [
'#type' => 'managed_file',
'#title' => t('Image'),
'#upload_location' => 'public://',
'#default_value' => 0,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->cleanValues();
print t('You WIN!');
exit;
}
}