public static function FileItem::validateMaxFilesize in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 251 - Contains \Drupal\file\Plugin\Field\FieldType\FileItem.
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).', array(
'@name' => $element['title'],
)));
}
}