public function FileTestForm::buildForm

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

array $form_state: An associative array containing the current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

drupal/core/modules/file/tests/file_test/lib/Drupal/file_test/Form/FileTestForm.php, line 26
Contains \Drupal\file_test\Form\FileTestForm.

Class

FileTestForm
File test form class.

Namespace

Drupal\file_test\Form

Code

public function buildForm(array $form, array &$form_state) {
  $form['file_test_upload'] = array(
    '#type' => 'file',
    '#title' => t('Upload a file'),
  );
  $form['file_test_replace'] = array(
    '#type' => 'select',
    '#title' => t('Replace existing image'),
    '#options' => array(
      FILE_EXISTS_RENAME => t('Appends number until name is unique'),
      FILE_EXISTS_REPLACE => t('Replace the existing file'),
      FILE_EXISTS_ERROR => t('Fail with an error'),
    ),
    '#default_value' => FILE_EXISTS_RENAME,
  );
  $form['file_subdir'] = array(
    '#type' => 'textfield',
    '#title' => t('Subdirectory for test file'),
    '#default_value' => '',
  );
  $form['extensions'] = array(
    '#type' => 'textfield',
    '#title' => t('Allowed extensions.'),
    '#default_value' => '',
  );
  $form['allow_all_extensions'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow all extensions?'),
    '#default_value' => FALSE,
  );
  $form['is_image_file'] = array(
    '#type' => 'checkbox',
    '#title' => t('Is this an image file?'),
    '#default_value' => TRUE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}