function FileItem::validateMaxFilesize
Same name and namespace in other branches
- 10 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::validateMaxFilesize()
- 11.x core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::validateMaxFilesize()
- 9 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::validateMaxFilesize()
- main core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::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 fieldSettingsForm().
File
-
core/
modules/ file/ src/ Plugin/ Field/ FieldType/ FileItem.php, line 248
Class
- FileItem
- Plugin implementation of the 'file' field type.
Namespace
Drupal\file\Plugin\Field\FieldTypeCode
public static function validateMaxFilesize($element, FormStateInterface $form_state) {
if (!empty($element['#value']) && !is_numeric(Bytes::toInt($element['#value']))) {
$form_state->setError($element, t('The "@name" 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).', [
'@name' => $element['title'],
]));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.