Index: content.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/content.admin.inc,v retrieving revision 1.181.2.49 diff -u -w -b -a -r1.181.2.49 content.admin.inc --- content.admin.inc 6 Oct 2008 15:19:05 -0000 1.181.2.49 +++ content.admin.inc 29 Oct 2008 22:09:49 -0000 @@ -968,6 +968,13 @@ '%field' => $field['widget']['label'], '%type' => $type['name'])), ); + $form['widget']['minimum_widgets'] = array( + '#type' => 'select', + '#title' => t("Number of widgets"), + '#description' => t("The number of widgets showing on the input form when there's no value entered, if this field takes unlimited values."), + '#options' => drupal_map_assoc(range(1,10)), + '#default_value' => variable_get('content_minimum_widgets_'. $field_name, '2'), + ); $form['widget']['weight'] = array( '#type' => 'hidden', '#default_value' => $field['widget']['weight'], @@ -1258,6 +1265,8 @@ $form_values = $form_state['values']; content_field_instance_update($form_values); + variable_set('content_minimum_widgets_'. $form_values['field_name'], $form_values['minimum_widgets']); + if (isset($_REQUEST['destinations'])) { drupal_set_message(t('Added field %label.', array('%label' => $form_values['label']))); $form_state['redirect'] = content_get_destinations($_REQUEST['destinations']); Index: content.node_form.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/content.node_form.inc,v retrieving revision 1.7.2.14 diff -u -w -b -a -r1.7.2.14 content.node_form.inc --- content.node_form.inc 4 Oct 2008 13:14:21 -0000 1.7.2.14 +++ content.node_form.inc 29 Oct 2008 22:23:02 -0000 @@ -156,25 +156,33 @@ $field_name = $field['field_name']; switch ($field['multiple']) { - case 0: + case 0: // 1 field, no multiple $max = 0; break; - case 1: + case 1: // unlimited $filled_items = content_set_empty($field, $items); + + // make the count different for no item (filled with an empty item by content_set_empty) and 1 item with data + $hook_is_empty = $field['module'] .'_content_is_empty'; + if (count($items) == 1 && $hook_is_empty($items[0], $field)) { + $minimum_item_count = variable_get('content_minimum_widgets_'. $field['field_name'], '2') - 1; + } + else{ + $minimum_item_count = count($items); + } $current_item_count = isset($form_state['item_count'][$field_name]) ? $form_state['item_count'][$field_name] - : count($items); + : $minimum_item_count; + // 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; - break; - default: + default: // fixed number of $field['multiple'] fields $max = $field['multiple'] - 1; break; } - $title = check_plain(t($field['widget']['label'])); $description = content_filter_xss(t($field['widget']['description']));