Project:Comment Upload
Version:6.x-1.0-alpha5
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I'm looking at limiting the number of file attachments to maybe 2 or 3 files only. Is this possible in anyway?

Thanks.

Comments

#1

Can I change this to critical because my boss wants this done by yesterday?

#2

No. Your boss is your problem ;)

You need to add some code to the AHAH callback and form validation handlers.

#3

I created a custom validation method in my template.php file and then added the function name to #validate in the $form array. I'm not really sure if I did correctly but it isn't working. I'm also not familiar with AHAH callbacks. I'll read up on this but here's the code for the validation.

function mytheme_comment_upload_form_validate($form, &$form_state){
if (empty($form_state['values']['op']) && (isset($form_state['clicked_button']) && $form_state['clicked_button']['#value'] != 'Attach')) {
    return;
} elseif(!empty($form_state['rebuild'])) {
    return;
}

$count = 0;

// Count number of files
foreach ($form['#comment_upload_storage'] as $fid => $file) {
$count++;
}
if ($count > 2) {
form_set_error('Step 2 (Optional): Insert a picture', t('You can only upload a maximum of two(2) files'));
} else {
comment_upload_comment_form_validate($form, &$form_state);
}
return;
}

#4

Looking for the same feature. Any progress on this? Sorry to ask. Thanks

#5

Subscribing