Hey guys,

I've always just needed a small number of values (<10) or an unlimited number of values for my filefield/imagefield implementations and never noticed that I couldn't set a value for the maximum number of field uploads between 10 and unlimited!??! Can this actually be true?

How can I allow users to upload, say, 30 files using a filefield?

Qasim

Comments

quicksketch’s picture

Project: FileField » Content Construction Kit (CCK)
Version: 6.x-3.10 » 6.x-2.9
Component: User interface » General
Category: bug » support

The ability to specify a number of items is provided by CCK, not FileField. You'd see the same behavior no matter what kind of field it was. In the past I've seen this limitation overcome by using a custom module and hook_form_alter() to change the options in the select list to include a greater number. CCK has no problem with setting the option to some arbitrary number, but it requires modifying the form to allow that number. I haven't seen a contrib module that provides this functionality, a custom module is probably the best route to take here.

marty.true’s picture

I need this exact same thing. Can anyone post the actual snippet, using hook_form_alter() to make this happen?
I need to have values of 1-24 before going to "Unlimited". Any help is greatly appreciated!!

jaydub’s picture

@xstatic I ended up having the same need as you so I can paste in what I did. In my case it involves CCK Multigroup forms so is slightly different but you should be able get the gist of it

if ($form_id == 'fieldgroup_group_edit_form' && $form['group_name']['#default_value'] == 'group_learning_ratings') {
    $form['settings']['multigroup']['multiple']['#options'] = array(1 => t('Unlimited'), 0 => 1) + drupal_map_assoc(range(2, 20));
}
manoloka’s picture

Hi Jaydub,

Where exactly did you paste that?

Thanks

jaydub’s picture

@manoloka you would add the code in a hook_form_alter anywhere in a custom module.

e.g. I have a module called csm_education_rating and I add a form alter hook to a custom module:

function csm_education_rating_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'fieldgroup_group_edit_form' && $form['group_name']['#default_value'] == 'group_learning_ratings') {
    $form['settings']['multigroup']['multiple']['#options'] = array(1 => t('Unlimited'), 0 => 1) + drupal_map_assoc(range(2, 20));
  }
}