function _imagefield_widget_validate in ImageField 5.2
Validate the widget.
2 calls to _imagefield_widget_validate()
- imagefield_js in ./
imagefield.module - Menu-callback for JavaScript-based uploads.
- imagefield_widget in ./
imagefield.module - Implementation of hook_widget().
File
- ./
imagefield.module, line 852 - Defines an image field type. imagefield uses content.module to store the fid, and the drupal files table to store the actual file data.
Code
function _imagefield_widget_validate($node, $field, $items) {
if ($field['required']) {
// Sum all the items marked for deletion, so we can make sure the end user
// isn't deleting all of the images.
$deleted = 0;
foreach ($items as $item) {
if ($item['flags']['delete']) {
++$deleted;
}
}
if (!count($items)) {
form_set_error($field['field_name'], t('@field is required. Please upload an image.', array(
'@field' => $field['widget']['label'],
)));
}
else {
if (count($items) == $deleted) {
form_set_error($field['field_name'], t('@field is required. Please uncheck at least one delete checkbox or upload another image.', array(
'@field' => $field['widget']['label'],
)));
}
}
}
}