Hi guys

Thank you for this awesome component.. It saved me a whole lot of custom code.

I have a quick feature request and I apologize in advance if this has already been discussed.... Rather than display all of the rows in the field, I would like to add some JQuery to dynamically add/delete the rows of the grouping similar to this jQuery plugin example.

http://www.datatables.net/examples/example_add_row.html

Any suggestions or feedback?

Thanks,
Greg

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not sure what do you exactly mean. The multigroup for unlimited number of items already provides a button to add more values, and another button for each subgroup to remove it.

Could you please clarify?

Anyway, I should say I'm afraid I won't have time to add more features here right now. But patches for review are welcome.

gsvitak’s picture

Hello

Thanks for the quick reply. For my use case, I only want a certain number of rows to be added so I am limiting the number of repeats to 5. I would love the "Add more" to be enabled no matter what the number of repeats is set to but limit the number of times someone could add based on this setting.

Thanks
G

markus_petrux’s picture

Version: 6.x-3.x-dev » 6.x-2.x-dev
Component: content_multigroup.module » content.module
Status: Postponed (maintainer needs more info) » Postponed

Oh, I see. Thanks for clarification. IIRC something similar has been mentioned in the CCK queue before, I just don't recall where it was exactly.

Well, I think something like this would have to be implemented first for multiple value fields in CCK2 (it is not strictly exclusive to multigroups), then it would be ported to CCK3, and also implemented for multigroups.

Postponing the issue until someone can come up with a patch for review.

markus_petrux’s picture

Title: add JQuery to dynamically add/delete the rows of the grouping » Provide "Add more values" button for fields with fixed number of multiple values

Better title.

markus_petrux’s picture

Title: Provide "Add more values" button for fields with fixed number of multiple values » Provide "Add more values" button for fields (and multigroups) with fixed number of multiple values
Component: content.module » General

I just marked #576540: 'Number of repeats' uses 'Add more' button as a duplicate of this issue.

csc4’s picture

Subscribing - this might help with default value and required field issues inside the multigroup too

tsi’s picture

Subscribing

markus_petrux’s picture

I just marked #483198: "Number of Values to Display" option for CCK fields as a duplicate of this issue.

afly’s picture

could i add more values in programmatic way ?

for example ,do some magic code in hook_form_alter ?

thekevinday’s picture

subscribing

kobnim’s picture

subscribing

avner’s picture

subscribing

acalderon’s picture

subscribing

Junro’s picture

Subscribe :)

I have to insert a lot of values in multigroup and I have to click on "add more values" for every row... it's very boring! lol

On the multigroup settings, we should have the possibility to set a number of values to display by default. And if we want more values, here we could use the "add more values" boutton.

giorgio79’s picture

Hello,

I have the same issue as #14, I would like to be able to provide around 100 rows by default, and I don't see how it is possible at the moment, as Multigroup only offers 10 rows or Unlimited, where the user has to add each row.

I would love to have an aribitrary default number of rows, or perhaps provide the number with some php magic, like the keys/values for select list.
(In my case I would like to have one row for each node in content type via node reference...)

giorgio79’s picture

Posted a separate feature request, as what me in #15 and #14 propose is slightly different but related:
#777574: Custom default value for Multigroup is currently max 10 or Unlimited

bcn’s picture

Status: Postponed » Closed (duplicate)

Marking as a duplicate of #344587: Enable 'add more' button for non-unlimited fields. because that one is older, and has a ~working patch.
Feel free to change back if you think I'm mistaken.

Junro’s picture

Status: Closed (duplicate) » Active

Not really the same feature :)

I tried the working patch of the other issue at #17 but it doesn't seem to affect this issue in king of way.

As the title says: it's for non-unlimited field...

This issue is for unlimited field. Instead of adding rows, row by row, we would like to add them 5 rows in on step. Or/and better, choose a default value in the field settings.

SeanA’s picture

Here's a backport of a patch for 3.x by Agileware that allows 1) setting the initial number of rows and 2) how many rows are added when "Add more" is clicked. Based on the 3.x version found here: #841914: Provide options to set how many fields are initially displayed and how many are added on click of "add more". Contains a database update that adds the new field properties.

"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." http://drupal.org/node/841914#comment-3209072

Agileware’s picture

Status: Active » Needs review

After comparing the patch in #19 to the patch at #841914-4: Provide options to set how many fields are initially displayed and how many are added on click of "add more" this issue should be marked as a duplicate of that issue and this patch posted there.

It's easier for people testing and maintainers if the issue is in one place.

hitfactory’s picture

FileSize
9.72 KB

Patch in #19 doesn't work as expected for fields. The number of initial fields and the number of fields added when the 'Add more' button is clicked are both one more than the values stored in the field settings form.

Attached patch makes a small modification to the original code from Agileware and SeanA to ensure that values set for 'Initial number of values' and 'Number of values per click' in the admin settings are fully respected.

Patch applies to latest 6.x-2.x-dev.

hitfactory’s picture

FileSize
9.72 KB

Attaching again with correct numbering. Patch itself is unchanged.

Agileware’s picture

@SeanA:

This is why it is a good idea to keep this patch in the same issue as the 6.x-3.x branch #841914: Provide options to set how many fields are initially displayed and how many are added on click of "add more"

Because they are essentially the same patch, if a bug is caught in one it should be fixed in both patches (unless it is a regression from your port the bug will almost certainly exist in both patches). The patches need to be kept the same for both branches.

The same patch should be in the same issue.

If you don't want to or have time to, when I get a chance I will get the two patches for the different versions in line and post them both to the same issue.

iMiksu’s picture

subscribing

SeanA’s picture

The bug fixed by #22 is not found in the 3.x version of this feature at #841914. That part of the code is where cck2 and cck3 differ in small but important ways, for example

in 2.x:
$max = ($current_item_count > count($filled_items))
? $current_item_count - 1
: $current_item_count;

and in 3.x:
$max = (!empty($deltas) ? max($deltas) : -1);
while (count($deltas) < $current_item_count) {
$max++;
$deltas[] = $max;
}

Since multivalues are handled slightly differently in cck2 and cck3, it seems to make sense to patch and test this feature (which is dealing with multivalues) separately for each branch. Bugs in one won't necessarily be found in the other.

KarenS’s picture

Status: Needs review » Closed (won't fix)

The way this works has already been ported to D7. And that code is frozen. We aren't adding new features in D6 for things that aren't available in D7. Otherwise you will just get started using something that will break when you update to D7.

Unless another maintainer jumps in to back this, this is going to have to be a 'won't fix'.

SeanA’s picture

Status: Closed (won't fix) » Active

It doesn't matter what code is "frozen" or what version we are talking about, this broken behavior should be fixed.

KarenS’s picture

Status: Active » Postponed (maintainer needs more info)

A 'feature request' is not 'broken behavior'. It is not 'broken' if you just don't like the way it works. If there is a bug that is something else, I don't see a bug report, I see a feature request. If there is a bug, please clarify what you think the bug is and provide a patch to fix the bug, not add a new feature.

abaddon’s picture

#22 doesnt work with flexifield, i still get 2 flexifields instead of just 1, but it worked for a simple text field actually i think this is an issue with flexifield and the way it handles these

SeanA’s picture

I think it's "broken" because it seems to me the only sensible way to implement multiple values is 1) to be able to set how many values are shown initially and 2) how many are added when clicking "add more". This setup covers every use case.

It seems to me the important thing isn't where we are in the D6/D7/D8 development cycle, but whether or not this is a good feature to have for Drupal. Isn't the way things work now the way it's been since D5, since the multiple values feature first got introduced? It wasn't implemented properly in the first place, that's why it's "broken".

KarenS’s picture

If we add a way to control that now, in D6, it will work until you try to upgrade to D7, when there will no longer be a way to do it. It won't be added to D7 because this functionality is in core in D7 and D7 is feature-frozen. So unless there is some way to hook_alter the way that D7 works so that a contrib module can add the feature there, it will be something that can only be done in D6.

thekevinday’s picture

It just so happens that the ability to do this via contrib was there in Drupal 7, but they removed it when I pointed out a bug: http://drupal.org/node/1014708

I think hook_field_read_field() and family functions can be used to do this in Drupal 7.

vewakayeh’s picture

Is there a simple way to add a limit, programmatically way, to this Unlimited selection?

for the non-programers maybe this it would be better than trying to convert the old patch #22 to apply on todays version of CCK.

sorry for the bad english:)

SeanA’s picture

vewakayeh, the patch at #22 should still work for the 2.x branch. It's really not that old and the parts of the code that it modifies might not have changed much, if at all. Have you tried applying it?

Be aware that this is a "dead end" feature however. No upgrade path if you go this route.

vewakayeh’s picture

It works perfect with version 2.9
and the total values can be extended from 10 to 100 easy with this http://drupal.org/node/680546
(at version 2.9 must be manual but its only one-line patch)

drupal is sooo addictive!!!

eighthourlunch’s picture

Patch on #22 very nearly works. :)

I'm now seeing "Add another item" on fields where I shouldn't--dates, and non multiple text fields that I don't want to be multiple. I'll see what I can correct.

eighthourlunch’s picture

Ok, I'm sure there's a cleaner way to do this, but this seems to be a good enough short fix.

In /modules/cck/includes/content.node_form.inc, you can use $disabled to change the button type to hidden:

$disabled = ($field['multiple'] != 1 && $delta >= $field['multiple']) ? TRUE : FALSE;

if ($disabled){

$button_type = 'hidden';

} else {

$button_type = 'submit';

}

$form_element[$field_name .'_add_more'] = array(
'#type' => $button_type,

kalimero’s picture

Incredibly useful patch

Thanks!!!