Hi,
I'm trying to mimic the #required validation for filefield inside my module.module file. I've tried the following, without any success:
if ($node->field_fattachment[0]['filepath'] == NULL) {
form_set_error('File Attachment', t('You did not upload your file, please do so in order to submit your work'));
}
or
if ($node->field_fattachment[0][value] == NULL) {
form_set_error('File Attachment', t('You did not upload your file, please do so in order to submit your work'));
}
or again
if (is_null($node->field_fattachment[0][value])) {
form_set_error('File Attachment', t('You did not upload your file, please do so in order to submit your work'));
}
I know it's possible to validate cck fields inside the .module file, because I am able to do it for checkboxes and text fields, but not with the filefield, it's like I can't find what to check, somehow... Any ideas?
THANKS!
Comments
Comment #1
dopry commentedwell have you tried to print r that node to see what's in it? and find the values... you're probably looking for field_attachment[0][fid]. i suggest you use print r to inspect the variable...