public static function S3fsCorsFileWidget::value in S3 File System CORS Upload 8
Form API callback. Retrieves the value for the file_generic field element.
This method is assigned as a #value_callback in formElement() method.
Overrides FileWidget::value
File
- src/
Plugin/ Field/ FieldWidget/ S3fsCorsFileWidget.php, line 132
Class
- S3fsCorsFileWidget
- Plugin implementation of the 's3fs_cors_widget' widget.
Namespace
Drupal\s3fs_cors\Plugin\Field\FieldWidgetCode
public static function value($element, $input = FALSE, FormStateInterface $form_state = NULL) {
if ($input) {
// Checkboxes lose their value when empty.
// If the display field is present make sure its unchecked value is saved.
if (empty($input['display'])) {
$input['display'] = $element['#display_field'] ? 0 : 1;
}
// Suppress processing of multiple uploads at the same time to force each
// uploaded file to be processed separately.
// Refer https://www.drupal.org/project/s3fs_cors/issues/2980155
if (in_array('upload', array_keys($input)) && is_null($input['upload'])) {
$input = FALSE;
}
}
// We depend on the managed file element to handle uploads.
$return = S3fsCorsFile::valueCallback($element, $input, $form_state);
// Ensure that all the required properties are returned even if empty.
$return += [
'fids' => [],
'display' => 1,
'description' => '',
];
return $return;
}