My client is always entering at least 20 lines so they are forced to click the Add more values button a lot. It would be nice if they could start with 25 lines and then add more if they needed.

This patch is sort of similar in the sense that it adds the button to Limited groups: http://drupal.org/node/344587

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

interestingaftermath’s picture

Category: support » feature
Junro’s picture

subscribe, Multigroup should really have this option.

interestingaftermath’s picture

Hi Junro, sounds like we are in the same boat. Here's what I've been trying (from my other issue):

I am looking to automate the adding of the multigroup rows so that my client can just tab through without having to grab the mouse to click the button. Anyone accomplished this already?

I am trying to use jQuery to handle this on blur() or focus() so that as they are tabbing through the fields another row is added automatically. My problem is that when using click() the focus on the field is lost so the user is forced to grab their mouse to click the next field anyhow.

The ideal workflow would be to tab through, auto add row and never leave focus of the current selected field.

Instead of simulating the click with jQuery, it may be better to use the content_multigroup_add_more_js function but I do not know what values it's expecting. Could someone else me with that?
Agileware’s picture

Status: Active » Needs review
FileSize
24.71 KB

Here is a patch that allows this functionality.

For multiple entry fields it adds options to set how many elements display initially and how many elements are added per click of the add more button.
It works when using a limited number of entries or for unlimited.

The same options are also added to multigroup fieldsets.

After applying the patch you have to run update.php for content and content_multigroup modules.

The same patch could be done for cck 6.x-2.x-dev if the content_multigroup parts are pulled out but I haven't had the time to make it yet.

Work on this patch was sponsored by interestingaftermath.

Agileware’s picture

Title: Start with 25 "repeats" and also provide "Add more values" » Provide options to set how many fields are initially displayed and how many are added on click of "add more"
Junro’s picture

Patch works great! Thanks a lot :)

Junro’s picture

I think the patch will not work with the new 3.x dev version.

No visible changes in content.node_form.inc but content.module has change a lot.

Try to port the patch to the new dev version is a pain in the....

@ Agileware

If you update the 3.x dev version and make the changes, could you attach your new content.module please.

Thanks :)

SeanA’s picture

Works as advertised (with cck-3.x of August 14 2010). The only problem I noticed is in the code comments, in 2 places it says "Make sure the initial value is >= the multiple value" it should be "Make sure the initial value is <= the multiple value". That is, it should read 'less than' instead of 'greater than'. Otherwise, nice work!

I've posted a patch for 2.x here: #530828: Provide "Add more values" button for fields (and multigroups) with fixed number of multiple values

Agileware’s picture

If that is just a port of the patch here it really should go in this issue and the other issue be made a duplicate of this one.

hey_germano’s picture

The patch in #4 is working great for me so far. Multigroup changed my (drupal) life, and this makes it even better. Thanks!

SeanA’s picture

Agileware, since there are separate 2.x and 3.x branches, and the differences between them affect this feature, I posted the 2.x patch in the older issue.

This feature is a must-have for cck, it's important to be able to specify the way the form is output to the user. Fixing it with your approach should take care of some related/duplicate issues as well:
#320313: CCK multiple values: two empty fields showing up - make it one or none?
#318307: multiple values: starting with one, not two tables
#787196: "Add another" for unlimited values starts with 2 fields
#777574: Custom default value for Multigroup is currently max 10 or Unlimited

interestingaftermath’s picture

Glad to hear I wasn't the only one in need of this feature. Agileware comes through again! :)

Anonymous’s picture

Subscribing.

DarkLight’s picture

Requesting!! :)

jibize’s picture

Thank you interestingaftermath!

I think it would definitely be big plus to add these options to cck 3.x.

interestingaftermath’s picture

Hey guys, I am not sure if the issue I am having is with the multigroup module or because of this patch.

Have any of you tried to add more than 80 lines to a node? I have had 3 clients that are using this patch mention that when they try to add more than 80 they get something like this:

An HTTP Error 500 occurred./content_multigroup/js_add_more/order/group_order

Any ideas?

SeanA’s picture

I was able to add about 120 lines to a node on my test site with no problems. My multigroup field only has 2 items (so far), a text field and a select list... are your multigroups more complex? Are all the sites on the same host? Maybe PHP is running out of memory, you can check the limit on the status report page. If you google drupal php.ini memory you can find ways to increase it.

interestingaftermath’s picture

SeanA: Good idea. All of the sites are on the same host, so I will check into the php memory. My multigroups are more complex with 6-7 text fields and a select list. I hope that's all it is but I will report back. Thanks!

interestingaftermath’s picture

SeanA: My PHP memory was set to 32mb and I increased it to 128mb. This allowed me to go much higher (160 and then I got bored so I gave up) but my browser feels like it's going to die at any minute. It freezes up and takes forever to load the next 20 lines. I imagine this is because of all the fields I have but I'm not sure why it gets slower as I go higher. Any thoughts?

TimelessDomain’s picture

just applied this patch from #4. the form doesn't save the options though, so it is impossible to tell if the rest of the coding works. any suggestions? when will this be committed?

SeanA’s picture

interestingaftermath, it may be due both to the javascript tabledrag stuff and also the way "add more" with cck multigroups works. The whole table has to be rebuilt when adding new elements, for the gritty details see the code and comments in function content_multigroup_add_more_js in content_multigroup.node_form.inc.

Patient: "Hey doc, it hurts when I do this."
Doctor: "Don't do that." ;-)

Timeless Domain, there are database updates with the patch (new fields to save the options)-- did you run update.php?

Marko B’s picture

I need this as well, thanx for patch.

alit’s picture

Patch #4 works good. Thank you Agileware!

KarenS’s picture

So if we added a feature like this it adds complexity to the code. Almost certainly it will break something for someone, these things always do. And then you get used to having it, but as soon as you upgrade to Drupal 7 you will no longer have this feature because core does not support it.

It is very late in the release cycle for the D6 version. Basically we are not adding anything to this version that won't work in D7 because it makes no sense to give people a new feature that will later disappear again. And we need to minimize changes for the thousands and thousands of sites that are already set up around the current feature set. And we just don't have time to fix bugs in D6 and work on D7 port/migration issues and also add and support new features in D6.

So this is unlikely to get in.

Agileware’s picture

@KarenS

If this will not make it into D6, then why not bump it up to be included in D7? Better than losing the ideas, feature and the community work altogether.

KarenS’s picture

You want to make this a core feature issue for D8 (too late for D7)? Go ahead if you like.

mattiasj’s picture

subscribing

3dloco’s picture

+1
[edit-update] Thanks a whole lot for this patch, I really hope it gets into cck 6.x-3.x-dev! This is working for me really well...using it with cck 6.x-3.x-dev as of 2010-Dec-24

Andrew Gorokhovets’s picture

+1

SeanA’s picture

"Drupal 7 you will no longer have this feature because core does not support it."

Then D7 is broken. When I first starting using multiple CCK fields, it was obvious the correct way to implement it would be to do what this patch does. It is absolutely imperative that we be able to control 1) how many fields are displayed initially and 2) how many are added when 'add more' is clicked. The borked way multiple fields was implemented in the first place is the problem. And now this is being kicked down the road to D8? Amazing! With the way multiple fields currently works, this should be considered a bug, not a feature request.

interestingaftermath’s picture

SeanA, I couldn't agree more. When I first found multigroup I was amazed that it couldn't do this already as it seemed quite necessary. After searching everywhere I found no one else talking about it so I contracted Agileware to build it. They did a great job and I'd love to see it added to multigroup core!

Junro’s picture

+1

interestingaftermath’s picture

Has anyone using this module upgraded to the latest dev version? Curious to see if it still works or if I should hang back.

Fidelix’s picture

subscribing...

rogueturnip’s picture

subscribe

3dloco’s picture

I have been testing it with cck 6.x-3.x-dev as of 2010-Dec-24 and it looks like when one is sharing fields across content types there are a couple of things that start happening:

1. For an imagefield that is shared across content types the settings get applied to all content types, like a global setting. This imagefield is not inside a multigroup.

2. For a filefield inside a Multigroup that is shared across content types the settings only get applied to the content type where the field was first created. The other content types with the filefield don't even get the settings to select the number of slots to open.

3. When one is saving the node, there is a validation error if there are slots are that are left empty or not used, so the user must close all the slots that they did not use.

For #1 & 2, I'd like to know if the patch covered/was intended for shared fields but it would be very useful if each field could have its own setting even if it is shared across content types.

For #3 Any pointer on how to avoid this validation for empty slots..?

Thanks,

KH

picxelplay’s picture

subscribing

Shadlington’s picture

Will it be possible for this to get into D7 via contrib?

KarenS’s picture

Status: Needs review » Postponed

As I noted in #24, this adds complexity to an already complex module. It alters the schema, which in turn affects the Content Migrate code for D6 to D7 upgrades. It also makes *this* module more complex, and it is already hugely time-consuming to debug all the permutations of the ways that field settings and group settings work together. I just spent two or three days trying to figure out the best way to make sure that required fields are only required in groups that are either not empty or required. It exhausts me to think about going back to re-visit all that code after adding in a huge patch like this to make sure things still work correctly.

Multigroup is a bit of a hack to work around some limitations in the way fields and forms work in D6. This problem can be solved much more elegantly in D7, so the upgrade path will be to migrate data from this module to some D7 successor (most likely Field Collections), not to use the same hacky solution in D7. The goal for D6 is to provide as much functionality as we can easily and realistically support. For the most part, it is feature-frozen, because adding new features will require extensive testing and debugging.

So this feature isn't likely to get in.

Shadlington’s picture

I'd like this feature in D7 - not specific to any multigroup-like implementation, but to all field types - i.e. I would like to be able to have a standard unlimited-value text field initially display with 5 items in the edit screen, as I know that for 90% of the time there will be around 5 items entered for this field and I'd like to save my users the time of clicking the button 4 times.

Should I raise a separate feature request for this?

Alphabool’s picture

The patch in #4 appears to be broken for 6.x-3.x-dev as of 2011-Mar-17.

I have adapted the patch to the most recent 6.x-3.x-dev release as of this writing, which is 2011-Mar-17. This patch does not reflect the issues in #36.

This was my first time rolling a patch so even though it seemed to come out okay I suggest applying with caution! :P

That said, I need to do more testing before I can say this works as expected but it doesn't seem to break anything significant, at least.

ulrikls’s picture

The patch in #41 seems broken in 6.x-3.0-alpha3. The attached screenshot show a multigroup containing a plain text field. Initially it shows four rows, and a click on "Add more" should add two rows. However it adds only one (partly) functional row and a yellow (dead) row. Another click will remove the first added row and add two more rows.

Any ideas on how to get this working? It would be really nice to have the ability to add e.g. ten more rows on a click on "Add more", even if there will be no upgrade path to Drupal 7.

Fidelix’s picture

Is it possible to achieve this in contrib for D7?

heresh’s picture

Title: Provide options to set how many fields are initially displayed and how many are added on click of "add more" » D7

Hi to all
Is there any workaround for D7?

Shadlington’s picture

Title: D7 » Provide options to set how many fields are initially displayed and how many are added on click of "add more"

You don't need to rename issues just to post a comment.

Junro’s picture

Patches are broken since a long time ago.

Everybody using this fonctionnality are still using a version of cck from July 16, 2010 (Date of Agileware patch at comment #4) ?

Is there someone who knows what to do about the patch in order to use the last dev version of cck ?

It will be very usefull and will avoid a lost of time to those using last dev version or alpha 3 of cck et would have this functionality...

Thanks :)

ps: For me, using Patch #41 results to the same bug in #42.

Junro’s picture

Here some informations:

Running the patch (I did it manually to be sure...) makes the Initial number of repeats work but not the Number of repeats per click.
When I click I have bug in #42 (see png image).

When I run update.php after installing the patch, I have :

  user warning: Duplicate column name 'initial' query: ALTER TABLE content_node_field ADD `initial` TINYINT NOT NULL DEFAULT 1 in www/includes/database.mysql-common.inc on line 306.
    user warning: Duplicate column name 'new_per_click' query: ALTER TABLE content_node_field ADD `new_per_click` TINYINT NOT NULL DEFAULT 1 in www/includes/database.mysql-common.inc on line 306.

The following queries were executed
content module
Update #6011

  Failed: ALTER TABLE {content_node_field} ADD `initial` TINYINT NOT NULL DEFAULT 1
    Failed: ALTER TABLE {content_node_field} ADD `new_per_click` TINYINT NOT NULL DEFAULT 1
    UPDATE {content_node_field} SET initial = 1 WHERE multiple = 0
    UPDATE {content_node_field} SET initial = multiple WHERE multiple != 0

I hope it will help to find what's wrong with the patch :)

SeanA’s picture

Hi Junro, I need this for a current project so I'll work on it soon. Very disappointing that we'll be stuck on D6 just to have this basic functionality.

Junro’s picture

Hi SeanA, very disappointing, indeed... :(

3dloco’s picture

Thanks @Alphabool for your patch...

@SeanA

I understand your pain...as I am also stuck in D6 for this and other functionality...I was wondering if you were able to fix it or track the issue for your project?

Thanks,

KH

semanthis’s picture

Just for the records, http://drupal.org/project/multivalue_settings kind of solves that problem for most cases (unluckyly not form my case...).