function FileTestSaveUploadFromForm::buildForm
Same name in other branches
- 9 core/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php \Drupal\file_test\Form\FileTestSaveUploadFromForm::buildForm()
- 10 core/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php \Drupal\file_test\Form\FileTestSaveUploadFromForm::buildForm()
- 11.x core/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php \Drupal\file_test\Form\FileTestSaveUploadFromForm::buildForm()
Overrides FormInterface::buildForm
File
-
core/
modules/ file/ tests/ file_test/ src/ Form/ FileTestSaveUploadFromForm.php, line 64
Class
- FileTestSaveUploadFromForm
- File test form class.
Namespace
Drupal\file_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['file_test_upload'] = [
'#type' => 'file',
'#multiple' => TRUE,
'#title' => $this->t('Upload a file'),
];
$form['file_test_replace'] = [
'#type' => 'select',
'#title' => $this->t('Replace existing image'),
'#options' => [
FileSystemInterface::EXISTS_RENAME => $this->t('Appends number until name is unique'),
FileSystemInterface::EXISTS_REPLACE => $this->t('Replace the existing file'),
FileSystemInterface::EXISTS_ERROR => $this->t('Fail with an error'),
],
'#default_value' => FileSystemInterface::EXISTS_RENAME,
];
$form['file_subdir'] = [
'#type' => 'textfield',
'#title' => $this->t('Subdirectory for test file'),
'#default_value' => '',
];
$form['extensions'] = [
'#type' => 'textfield',
'#title' => $this->t('Allowed extensions.'),
'#default_value' => '',
];
$form['allow_all_extensions'] = [
'#title' => t('Allow all extensions?'),
'#type' => 'radios',
'#options' => [
'false' => 'No',
'empty_array' => 'Empty array',
'empty_string' => 'Empty string',
],
'#default_value' => 'false',
];
$form['is_image_file'] = [
'#type' => 'checkbox',
'#title' => $this->t('Is this an image file?'),
'#default_value' => TRUE,
];
$form['error_message'] = [
'#type' => 'textfield',
'#title' => $this->t('Custom error message.'),
'#default_value' => '',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.