You are here

public function S3fsCorsImageWidget::settingsForm in S3 File System CORS Upload 8

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form definition for the widget settings.

Overrides ImageWidget::settingsForm

File

src/Plugin/Field/FieldWidget/S3fsCorsImageWidget.php, line 39

Class

S3fsCorsImageWidget
Plugin implementation of the 's3fs_cors_widget' widget.

Namespace

Drupal\s3fs_cors\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements = parent::settingsForm($form, $form_state);
  $elements['max_filesize'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Maximum upload size'),
    '#description' => $this
      ->t('Enter a value like "512" (bytes), "80 KB" (kilobytes), "50 MB" (megabytes) or "2 GB" (gigabytes) in order to restrict the allowed file size. This value will override any value specified in the field configuration settings.'),
    '#default_value' => $this
      ->getSetting('max_filesize'),
    '#size' => 10,
    '#weight' => 5,
    '#element_validate' => [
      [
        $this,
        'settingsMaxFilesizeValidate',
      ],
    ],
  ];
  return $elements;
}