Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
For different reason, sometimes is needed to restrict the number the user could select. I would like to know if there is some way to achieve it now.
thank you
Comment | File | Size | Author |
---|---|---|---|
#21 | 724686.patch | 6.19 KB | bojanz |
#16 | views-bulk-operations_radios_724686_16.patch | 9.04 KB | dafeder |
#17 | views-bulk-operations_radios_724686_17.patch | 7.01 KB | dafeder |
#13 | limit_to_one.patch | 3.18 KB | Miguel.Andrade |
#7 | limit_to_one.patch | 3.74 KB | dealancer |
Comments
Comment #1
kansaj CreditAttribution: kansaj commentedI mean the number of items
Comment #2
infojunkieRight now there isn't. We can keep this as a feature request, although I doubt I'll get to it soon.
Comment #3
kansaj CreditAttribution: kansaj commentedthank you for the prompt answer ! Hope to keep as request for new feature no matter the time horizon .
cheers
Comment #4
afly CreditAttribution: afly commentedi think it would be great if vbo can restrict the number to only one and convert checkbox into radiobutton then act as a table select widget .
Comment #5
kansaj CreditAttribution: kansaj commentedthe radio button should be according to me new feature too, but the selector is a terrific feature, which provides much of flexibility and opportunities :)
Comment #6
dealancer CreditAttribution: dealancer commentedsubscribing.
Comment #7
dealancer CreditAttribution: dealancer commentedHi guys. I've made a patch. Now you could limit amount of selected check-box to one only. There is some php code that does validation and some jquery that unchecks checkboxes.
Comment #8
infojunkieRe #7: Thanks for your patch. However, I would prefer having a general-purpose setting in the VBO style settings to determine how many items can be selected (min, max). Then the JS code and form validation code can check on those numbers.
Comment #9
dealancer CreditAttribution: dealancer commentedYeah, there is setting in VBO style: checkbox. Next time I will try to add min and max fields.
Comment #10
infojunkieComment #11
infojunkiePlease submit patches against 6.x-1.x-dev as VBO 6.x-1.10-beta2 and above support both Views 2.x and 3.x.
Comment #12
k4ml CreditAttribution: k4ml commentedI've also come to a situation where I need to limit the selection to 1, merely making it more like a radio button. For now, this js would just uncheck all the checkboxes except for one being checked:-
I did this before I found this issue and the patch in #7.
Comment #13
Miguel.Andrade CreditAttribution: Miguel.Andrade commentedHi,
This is a great feature. I actually just need the "select only one" version. I use it with rulesets so I can let users select some content and then run an action on it, but in most cases makes no sense to select more than one.
The proposed patch #7 did not applied completely on version = "6.x-1.10" so here's a new one.
Comment #14
dafederI'm trying to solve this problem in D7... I think a radio button option is very valuable for many use cases. I'm working on a patch that would add an option to the vbo config for "force single" and use radio buttons instead of checkboxes. I'm not sure it would be back-portable because it relies on views 3's views_form api.
Comment #15
infojunkieI can't accept the patch in #13. To limit selection to just one item, the view should render radio buttons, not checkboxes.
For a truly general solution, here's what should happen:
* Allow admin to specify min and max count of items - provide special case option of 1 item with radio buttons
* On the view page, show those numbers in a themable way
* On the view page, show the number of currently selected items in a themable way
* On the view page, restrict selection to given range
* Validate submission
Comment #16
dafederHere is my initial patch for radio buttons, using a "force single" option in the vbo options. I don't know how easy this would be to backport to D6.
EDIT: Please disregard and use patch in #17
Comment #17
dafederSorry, number of problems with that patch. Please disregard and use this updated one.
Comment #18
bojanz CreditAttribution: bojanz commentedYou're reverting a notice fix I made.
'#parents' should be set to array($this->options['id']), you have no guarantee that the views field will always be called "views_bulk_operations'
Other than that, patch looks ready.
7.x can get the "range" functionality another day. The "force single" option is nifty enough. I love it how easy views_form makes this.
Comment #19
dafederWhoops, that revert was not intentional, I upgraded the module before committing my changes locally and ended up with a bunch of reverts like that in the patch. Thought I had corrected them.
Do you need me to submit a new patch?
Comment #20
bojanz CreditAttribution: bojanz commentedNah, I can make the change before commit.
Comment #21
bojanz CreditAttribution: bojanz commentedImproved the patch a bit and committed it.
Returning the issue back to infojunkie.
For reference, attaching the patch that I committed.
Rereading it shows me how fond I've become of empty() even when not needed. Fixed that in a followup:
http://drupalcode.org/project/views_bulk_operations.git/commitdiff/4e8de...
Comment #22
bojanz CreditAttribution: bojanz commented6.x-1.x is feature frozen at this point.