So, I like being able to choose the "Maximum number of values users can enter for this field." However, I don't want that maximum to be shown right off the start because it fills up the page. So, it would be great to also be able to enter the beginning number of image upload fields initially shown.

With that, I could set it up so there is 2 values by default, and users can click the "Add another item" button to open up a maximum of eight image upload fields.

Comments

drewish’s picture

Project: ImageField » Content Construction Kit (CCK)
Version: 6.x-3.0-alpha2 » 6.x-2.x-dev
Component: Miscellaneous » General

that functionality is provide by cck... that said this is probably a duplicate of an existing issue in that queue.

OneTwoTait’s picture

Oh ya? I don't see it... so how would you select the beginning number of values to use?

yched’s picture

Title: Beginning number of photo upload fields » Enable 'add more' button for non-unlimited fields.

taite11 : currently not possible. What drewish means is that it is a request for CCK, who manages widgets display, not for imagefield.

Sort of related to #320313: CCK multiple values: two empty fields showing up - make it one or none? - which is on my list of things to review / tackle. Karen and I both have little time right now, plus our focus is shifting to Fields in D7 core, so this list doesn't move too fast right now...

The "don't show 10 widgets straight on if number of values is 10" part is a separate request, though. Currenlty the 'add more' button is only used for 'unlimited' multiple fields.

skizzo’s picture

I would second the OP request. In my use case I must impose a limit on the number of images entered by user: that currently would result in 40 items being displayed, even to users that need to enter just one or two... As I understand it, this feature request is being handled separately from #320313. Otherwise please mark it as duplicate. Thank you.

pribeh’s picture

bump, uber-bump, super-quantum-bump! This is exactly what my patients have requested. Can anybody help? as the maintainers appear to have their hands full. I'm just a limey themer.

ioskevich’s picture

I did it the dirty way on theme level overriding theme_content_multiple_values function.

This is not right way to do it, I guess, but at least it works and doesn't require CCK or Fielfield module code modification:

So, first we need to override standard theme function:

Copy the function code (theme_content_multiple_values($element)) from CCK's content.module to your module or theme (template.php) and rename it to: phptemplate_content_multiple_values(&$element) (I guess THEME_NAME_content_multiple_values(&$element) will also work, but I needed it at module's level).

After these lines:

$field_name = $element['#field_name'];
$field = content_fields($field_name);
$output = '';

add something like:

	if($field_name == 'YOUR_FIELFIELD_NAME'){
		foreach($element as $key => $value){
			if (is_numeric($key) && $key >= FIELDS_LIMIT){ //This check can be more elegant, I guess...
				unset($element[$key]);
				unset($element['field_report_photo_add_more']);
			}
		}
	}

This worked for me, and was quick and cheap solution.

dboulet’s picture

I'd like to see this feature worked into the module, should this go in to 3.x first?

In my opinion, this would be huge improvement to the user interface. For example, if I want a user to upload a maximum of 20 images using Imagefield, I don't want to present them with 20 image input fields... that's a little insane :).

tomsm’s picture

Indeed, this feature is very welcome!

Bilmar’s picture

+1 subscribing

dboulet’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Component: General » Usability
Status: Active » Needs review
StatusFileSize
new7.04 KB

Here's a first patch for CCK 3. Please review and provide feedback.

dboulet’s picture

Improved patch.

Bilmar’s picture

very cool! patching went smoothly and I tested with cck field type 'Text' 'File' and 'Date'.

This patch doesn't seem to affect Widget Type 'Select List' or 'Check boxes/Radio buttons'. Checkboxes/Radios I understand there is no need, but for Select List it would be very cool if we would be able to select one item from the Select List and have the option to 'Add another item' (as per the limit set) and select another item from the Select List. Would this be a possibility?

For the type 'File' I tested with imagefield crop and widget type 'image with cropping'. This looks very cool with the option to upload additional images and each with its own crop preview. The 'Remove this item' and 'Restore this item' worked very smoothly too.

In my use case, this new feature is awesome as I wanted to limit images to 5 but not show all 5 upload fields at once. This allows users to click for additional images to upload..looks very professional.

Thanks for the great work dboulet!

Please let me know if further information is needed with testing.

rburgundy’s picture

+1 for 'add more' with Select List choices
thanks for the great patch. tested and looks awesome

skizzo’s picture

Will this patch be committed to CCK3 after testing?
Will it be backported to CCK2?

I just moved from 6.x-2.6 to 6.x-3.x-dev in order to use this
feature, but the patch doesn't seem to apply cleanly

patching file content.module
patching file includes/content.node_form.inc
Hunk #6 FAILED at 363.
1 out of 8 hunks FAILED -- saving rejects to file includes/content.node_form.inc.rej

dboulet’s picture

Rerolled against latest dev.

YK85’s picture

Status: Needs review » Reviewed & tested by the community

subscribing - tested patch @ #15 and it works.
thanks for actively updating this patch to the newest dev

YK85’s picture

Any chance of seeing this added to the newest dev release?
Great work dboulet!

Bilmar’s picture

tested the patch at #15 and everything works without any issues. great new feature!
can the maintainers of cck let us know if this may be considered to be added to the latest dev version?
thank you!

robby.smith’s picture

Hi,

This patch is a very cool feature to the non-unlimited fields.

Some additional cool features would be if we were able to change the messages:
"You may enter a maximum of 4 values for this field."
"Maximum reached. You must remove values to be able to add more."

For example, if the field is for uploading images it would be nice to say:
"You may upload a maximum of 4 pictures."
"Maximum reached. You must remove pictures to be able to add more."

Additionally, hiding [Add another item] button once the maximum is reached would be nice.

Thanks so much for the hard work!

bcn’s picture

Marked #530828: Provide "Add more values" button for fields (and multigroups) with fixed number of multiple values (which itself has a few duplicates) as duplicate of this issue.

edit:Upon closer inspection, these are different issues.

karens’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

This is too complicated a change to commit this late in the cycle. It has the potential to break other things and no one has time to babysit it to be sure it doesn't. Plus everything will be different in Drupal 7 anyway.

mark.’s picture

.

interestingaftermath’s picture

This patch adds "Add more values" to groups with a limited number of entries. Is there any way to take this in a different direction and start by showing more than 10 (e.g. 20-25) and then allow the user to use the "Add more values" to extend that 25 to whatever they wanted?

I know this is a slightly different topic so I've created a new issue: http://drupal.org/node/841914

agileware’s picture

The patch created for #841914: Provide options to set how many fields are initially displayed and how many are added on click of "add more" would allow for this functionality.
If you are interested, test and review that patch, although the result could potentially be the same as this issue's won't fix status.

agileware’s picture