Skip to content
Snippets Groups Projects
Select Git revision
  • b201c0546c412cfdf03b79139ca37b3a731beb67
  • 11.x default protected
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

FileTestForm.php

Blame
  • Alex Pott's avatar
    Issue #2111209 by Xano: Fixed Rename FormInterface::getFormID() to FormInterface::getFormId().
    Alex Pott authored
    b201c054
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    FileTestForm.php 3.23 KiB
    <?php
    /**
     * @file
     * Contains \Drupal\file_test\Form\FileTestForm.
     */
    
    namespace Drupal\file_test\Form;
    
    use Drupal\Core\Form\FormInterface;
    
    /**
     * File test form class.
     */
    class FileTestForm implements FormInterface {
    
      /**
       * {@inheritdoc}
       */
      public function getFormId() {
        return '_file_test_form';
      }
    
      /**
       * {@inheritdoc}
       */
      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;
      }