You are here

public static function VideoUploadWidget::validateMaxFilesize in Video 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/VideoUploadWidget.php \Drupal\video\Plugin\Field\FieldWidget\VideoUploadWidget::validateMaxFilesize()

Form API callback.

Ensures that a size has been entered and that it can be parsed by \Drupal\Component\Utility\Bytes::toInt().

This function is assigned as an #element_validate callback in settingsForm().

File

src/Plugin/Field/FieldWidget/VideoUploadWidget.php, line 142

Class

VideoUploadWidget
Plugin implementation of the 'video_upload' widget.

Namespace

Drupal\video\Plugin\Field\FieldWidget

Code

public static function validateMaxFilesize($element, FormStateInterface $form_state) {
  if (!empty($element['#value']) && Bytes::toInt($element['#value']) == 0) {
    $form_state
      ->setError($element, t('The option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).'));
  }
}