Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I'm using CCK 6.x-3.x-dev with FileField 6.x-3.9.
I define a filefield type file in a custom content type.
The configuration is : required checked and number of value set to one.
The upload works great even when the user forget to click upload.
But if he forgets to select a file, it generates no warning. It happens on all browsers.
This error is huge that I think I'm doing wrong something.
Thanks for your advices
Comments
Comment #1
Vangoce CreditAttribution: Vangoce commentedNo idea?
Comment #2
quicksketchIs this in conjunction with Content Profile module? That module has a long-standing incompatibility with FileFields on the registration form. Otherwise, I can't reproduce this issue so it's hard to suggest anything.
Comment #3
Vangoce CreditAttribution: Vangoce commentedThank you for the answer. We use this module. We'll try to remove it and check.
Comment #4
Vangoce CreditAttribution: Vangoce commentedNo link to Content Profile module. I solved the problem by updating the function filefield_widget_validate(&$element, &$form_state) in filefield_widget.inc. So now, we add an error if the filefield is empty and the attribut Required is true.
else {
form_error($element, t('The file referenced by the %field field does not exist.', array('%field' => $element['#title'])));
}
}
+ else {
+ if ($element['#required']) {
+ form_error($element, t('The file field %field is required', array('%field' => $element['#title'])));
+ }
+ }
}
Comment #5
quicksketchClosing this issue as it seems like @Vangoce found a solution... but it *shouldn't* be necessary. FileFields should properly validate like any other field. I personally can't reproduce a problem.