Index: content.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/Attic/content.install,v
retrieving revision 1.85.2.33
diff -u -p -r1.85.2.33 content.install
--- content.install	14 Jul 2009 22:17:05 -0000	1.85.2.33
+++ content.install	1 Sep 2010 12:19:13 -0000
@@ -141,6 +141,8 @@ function content_schema() {
       'db_columns'      => array('type' => 'text', 'size' => 'medium', 'not null' => TRUE, 'serialize' => TRUE),
       'active'          => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0),
       'locked'          => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0),
+      'initial'         => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 1),
+      'new_per_click'   => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 1),
     ),
     'primary key' => array('field_name'),
   );
@@ -618,4 +620,25 @@ function content_update_6010(&$sandbox)
     $ret['#finished'] = 1 - count($sandbox['tables']) / $sandbox['count'];
   }
   return $ret;
+}
+
+/**
+ * Add 'initial' & 'new_per_click' properties for fields.
+ */
+function content_update_6011() {
+  if ($abort = content_check_update()) {
+    return $abort;
+  }
+
+  $ret = array();
+  drupal_load('module', 'content');
+  db_add_field($ret, content_field_tablename(), 'initial', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 1));
+  db_add_field($ret, content_field_tablename(), 'new_per_click', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 1));
+
+  // Set the initial value for existing fields so that there is no change in functionality.
+  $ret[] = update_sql("UPDATE {" . content_field_tablename() . "} SET initial = 1 WHERE multiple = 0");
+  $ret[] = update_sql("UPDATE {" . content_field_tablename() . "} SET initial = multiple WHERE multiple != 0");
+
+  variable_set('content_schema_version', 6011);
+  return $ret;
 }
\ No newline at end of file
Index: includes/content.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/Attic/content.admin.inc,v
retrieving revision 1.181.2.76
diff -u -p -r1.181.2.76 content.admin.inc
--- includes/content.admin.inc	2 Nov 2009 21:21:24 -0000	1.181.2.76
+++ includes/content.admin.inc	1 Sep 2010 12:19:13 -0000
@@ -1150,11 +1150,25 @@ function content_field_edit_form(&$form_
   $description .= '<br/><strong>'. t('Warning! Changing this setting after data has been created could result in the loss of data!') .'</strong>';
   $form['field']['multiple'] = array(
     '#type' => 'select',
-    '#title' => t('Number of values'),
+    '#title' => t('Total number of values'),
     '#options' => array(1 => t('Unlimited'), 0 => 1) + drupal_map_assoc(range(2, 10)),
     '#default_value' => $field['multiple'],
     '#description' => $description,
   );
+  $form['field']['initial'] = array(
+    '#type' => 'select',
+    '#title' => t('Initial number of values'),
+    '#options' => drupal_map_assoc(range(1, 25)),
+    '#default_value' => $field['initial'],
+    '#description' => t("The number of values that will be presented initially. This number cannot be greater that the 'Total number of values'."),
+  );
+  $form['field']['new_per_click'] = array(
+    '#type' => 'select',
+    '#title' => t('Number of values per click'),
+    '#options' => drupal_map_assoc(range(1, 10)),
+    '#default_value' => $field['new_per_click'],
+    '#description' => t("The number of values that will be added for each click of the 'Add more' button. Regardless of what this is set to, it won't add more than the 'Total number of values'."),
+  );

   $form['field']['previous_field'] = array(
     '#type' => 'hidden',
@@ -1313,6 +1327,12 @@ function content_field_edit_form_validat
       }
     }
   }
+
+  // Make sure the initial value is less than or equal to the multiple value.
+  if (($form_values['multiple'] == 0 && $form_values['initial'] > 1) ||
+      ($form_values['multiple'] > 1 && $form_values['initial'] > $form_values['multiple'])) {
+    form_set_error('initial', t('The initial number of values cannot be greater than the total number of values.'));
+  }
 }

 /**
Index: includes/content.node_form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/Attic/content.node_form.inc,v
retrieving revision 1.7.2.22
diff -u -p -r1.7.2.22 content.node_form.inc
--- includes/content.node_form.inc	14 Aug 2010 05:17:39 -0000	1.7.2.22
+++ includes/content.node_form.inc	1 Sep 2010 12:19:14 -0000
@@ -155,19 +155,14 @@ function content_multiple_value_form(&$f
       $max = 0;
       break;
     case 1:
+    default:
       $filled_items = content_set_empty($field, $items);
-      $current_item_count = isset($form_state['item_count'][$field_name])
-                            ? $form_state['item_count'][$field_name]
-                            : count($items);
-      // We always want at least one empty icon for the user to fill in.
-      $max = ($current_item_count > count($filled_items))
-              ? $current_item_count - 1
-              : $current_item_count;
+      $current_item_count = max($field['initial'], (isset($form_state['item_count'][$field_name]) ?
+      $form_state['item_count'][$field_name] : count($items)));
+      // Show the exact number of items no more, no less.
+      $max = $current_item_count - 1;

       break;
-    default:
-      $max = $field['multiple'] - 1;
-      break;
   }

   $title = check_plain(t($field['widget']['label']));
@@ -196,7 +191,7 @@ function content_multiple_value_form(&$f

       // Add an input field for the delta (drag-n-drop reordering), which will
       // be hidden by tabledrag js behavior.
-      if ($field['multiple'] >= 1) {
+      if ($field['multiple'] >= 1 || $field['multiple'] > $field['initial']) {
         // We name the element '_weight' to avoid clashing with column names
         // defined by field modules.
         $element['_weight'] = array(
@@ -212,12 +207,16 @@ function content_multiple_value_form(&$f
   }

   // Add AHAH add more button, if not working with a programmed form.
-  if ($field['multiple'] == 1 && empty($form['#programmed'])) {
+  if (($field['multiple'] == 1 || $field['multiple'] > $field['initial']) && empty($form['#programmed'])) {
     // Make sure the form is cached so ahah can work.
     $form['#cache'] = TRUE;
     $content_type = content_types($field['type_name']);
     $field_name_css = str_replace('_', '-', $field_name);

+    // If we are not using unlimited values and we now have max deltas disable the add button.
+    // This covers us for users who don't have javascript.
+    $disabled = ($field['multiple'] != 1 && $delta >= $field['multiple']) ? TRUE : FALSE;
+
     $form_element[$field_name .'_add_more'] = array(
       '#type' => 'submit',
       '#name' => $field_name .'_add_more',
@@ -237,6 +236,7 @@ function content_multiple_value_form(&$f
       // the relevant field using these entries.
       '#field_name' => $field_name,
       '#type_name' => $field['type_name'],
+      '#disabled' => $disabled,
     );

     // Add wrappers for the fields and 'more' button.
@@ -261,7 +261,12 @@ function content_add_more_submit($form,

   // Make the changes we want to the form state.
   if ($form_state['values'][$field_name][$field_name .'_add_more']) {
-    $form_state['item_count'][$field_name] = count($form_state['values'][$field_name]);
+    if ($form['#field_info'][$field_name]['multiple'] == 1) {
+      $form_state['item_count'][$field_name] = count($form_state['values'][$field_name]) + $form['#field_info'][$field_name]['new_per_click'] - 1;
+    }
+    else {
+      $form_state['item_count'][$field_name] = min(count($form_state['values'][$field_name]) + $form['#field_info'][$field_name]['new_per_click'] - 1, $form['#field_info'][$field_name]['multiple']);
+    }
   }
 }

@@ -272,7 +277,7 @@ function content_add_more_js($type_name_
   $type = content_types($type_name_url);
   $field = content_fields($field_name, $type['type']);

-  if (($field['multiple'] != 1) || empty($_POST['form_build_id'])) {
+  if (($field['multiple'] != 1 && $field['multiple'] <= $field['initial']) || empty($_POST['form_build_id'])) {
     // Invalid request.
     drupal_json(array('data' => ''));
     exit;
@@ -318,7 +323,14 @@ function content_add_more_js($type_name_
   $_POST[$field_name] = _content_sort_items($field, $_POST[$field_name]);

   // Build our new form element for the whole field, asking for one more element.
-  $form_state['item_count'] = array($field_name => count($_POST[$field_name]) + 1);
+  if ($field['multiple'] == 1) {
+    $delta = max(array_keys($_POST[$field_name])) + $field['new_per_click'];
+    $form_state['item_count'] = array($field_name => count($_POST[$field_name]) + $field['new_per_click']);
+  }
+  else {
+    $delta = min(max(array_keys($_POST[$field_name])) + $field['new_per_click'], $field['multiple'] - 1);
+    $form_state['item_count'] = array($field_name => min(count($_POST[$field_name]) + $field['new_per_click'], $field['multiple']));
+  }
   $form_element = content_field_form($form, $form_state, $field);
   // Let other modules alter it.
   drupal_alter('form', $form_element, array(), 'content_add_more_js');
@@ -331,6 +343,11 @@ function content_add_more_js($type_name_
     $form[$field_name] = $form_element[$field_name];
   }

+  // If we are not using unlimited values and we now have max deltas, disable the add button.
+  if ($field['multiple'] != 1 && $delta + 1 >= $field['multiple']) {
+    $form[$field_name][$field_name . '_add_more']['#disabled'] = TRUE;
+  }
+
   // Save the new definition of the form.
   $form_state['values'] = array();
   form_set_cache($form_build_id, $form, $form_state);
