function FileTestForm::buildForm
Same name in other branches
- 8.9.x core/modules/file/tests/file_test/src/Form/FileTestForm.php \Drupal\file_test\Form\FileTestForm::buildForm()
- 10 core/modules/file/tests/file_test/src/Form/FileTestForm.php \Drupal\file_test\Form\FileTestForm::buildForm()
- 11.x core/modules/file/tests/file_test/src/Form/FileTestForm.php \Drupal\file_test\Form\FileTestForm::buildForm()
Overrides FormInterface::buildForm
1 call to FileTestForm::buildForm()
- FileRequiredTestForm::buildForm in core/
modules/ file/ tests/ file_test/ src/ Form/ FileRequiredTestForm.php - Form constructor.
1 method overrides FileTestForm::buildForm()
- FileRequiredTestForm::buildForm in core/
modules/ file/ tests/ file_test/ src/ Form/ FileRequiredTestForm.php - Form constructor.
File
-
core/
modules/ file/ tests/ file_test/ src/ Form/ FileTestForm.php, line 24
Class
- FileTestForm
- File test form class.
Namespace
Drupal\file_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['file_test_upload'] = [
'#type' => 'file',
'#title' => t('Upload a file'),
];
$form['file_test_replace'] = [
'#type' => 'select',
'#title' => t('Replace existing image'),
'#options' => [
FileSystemInterface::EXISTS_RENAME => t('Appends number until name is unique'),
FileSystemInterface::EXISTS_REPLACE => t('Replace the existing file'),
FileSystemInterface::EXISTS_ERROR => t('Fail with an error'),
],
'#default_value' => FileSystemInterface::EXISTS_RENAME,
];
$form['file_subdir'] = [
'#type' => 'textfield',
'#title' => t('Subdirectory for test file'),
'#default_value' => '',
];
$form['extensions'] = [
'#type' => 'textfield',
'#title' => 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' => t('Is this an image file?'),
'#default_value' => TRUE,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.