public function FileModuleTestForm::submitForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php \Drupal\file_module_test\Form\FileModuleTestForm::submitForm()
- 10 core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php \Drupal\file_module_test\Form\FileModuleTestForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- core/
modules/ file/ tests/ file_module_test/ src/ Form/ FileModuleTestForm.php, line 71
Class
- FileModuleTestForm
- Form controller for file_module_test module.
Namespace
Drupal\file_module_test\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form['#tree']) {
$uploads = $form_state
->getValue([
'nested',
'file',
]);
}
else {
$uploads = $form_state
->getValue('file');
}
if ($form['nested']['file']['#extended']) {
$uploads = $uploads['fids'];
}
$fids = [];
foreach ($uploads as $fid) {
$fids[] = $fid;
}
\Drupal::messenger()
->addStatus($this
->t('The file ids are %fids.', [
'%fids' => implode(',', $fids),
]));
}