Problem/Motivation

Good module, needs a D7 and soon a D8 version

Proposed resolution

Port to D7

Remaining tasks

Make work with form api
Make work with field formatter api

User interface changes

When this is done there will be options for select checkboxes to select all, toggle, or select none.

API changes

Adds the option to make select boxes select all in the form api.

Data model changes

none, adds options to field formatter.

Original Summary

Are there any plans to make a version for Drupal 7?

Comments

mgifford’s picture

Yup. I'm curious about that too!

markus_petrux’s picture

Sure. Though, I'm not sure when I'll have the time.

If you're interested, I would be happy to grant maintainership access to anyone of you, both.

mgifford’s picture

Thanks. I wish I had the time to take it on.

If I need to upgrade it myself I'll certainly post a patch. And thanks if and when you do get the time. Not easy to do.

sachbearbeiter’s picture

into core

breos’s picture

Hello all

I have tried to port this to D7, this are the steps I have done:

checkall.module
Line 116
Before
$element['#attributes']['class'] = 'form-checkall '. $class;
After
$element['#attributes']['class'] = array('form-checkall '. $class);
Line 119
Before
$element['#attributes']['class'] .= ' form-checkall '. $class;
After
$element['#attributes']['class'] .= array(' form-checkall '. $class);

Line 129
Before
$element[$key]['#attributes']['class'] = $class;
After
$element[$key]['#attributes']['class'] = array($class);

Line 132
Before
$element[$key]['#attributes']['class'] .= ' '. $class;
After
$element[$key]['#attributes']['class'] .= array(' '. $class);

checkall.js
Addded
(function ($) {
at the start of the code and
})(jQuery);
at the end of the code

Modified behaviors function:
Before

Drupal.behaviors.checkAll = function(context) {

  $('.form-checkall:not(.checkall-processed)', context).each(function() { Drupal.checkAll.attach(this); });
};

After

Drupal.behaviors.checkAll = { 

 attach: function(context,settings) {

  $('.form-checkall:not(.checkall-processed)', context).each(function() { Drupal.checkAll.attach (this,settings);});
 }

};

References about this change:
http://drupal.org/node/756722 (see BEHAVIORS)

And now the last change, all references to
Drupal.settings.checkall have been change to settings. only
Example:
Line 27 was:

 if (Drupal.settings.checkall && Drupal.settings.checkall.groups) {

Now is:

 if (settings.checkall && settings.checkall.groups) {

Obviusly, you will have to change the checkall.info to work in D7 too :-P

I know this is not a patch and pershaps has a lot of bugs, but Im not a developer.
If someone with more knowledge can check this, I'm sure a lot of us will be very grateful

Hope this helps you all who needs this module working in D7 and thanks a lot to Markus for develop it to D6

klonos’s picture

Title: Is it planned to make a release for Drupal 7? » Port Checkall module to drupal 7.
Issue tags: +D7 porting, +port to d7, +d7 ports

...less vague title + proper tags.

avpaderno’s picture

Title: Port Checkall module to drupal 7. » Is it planned to make a release for Drupal 7?

The title is not vague. This is a support request that is asking to the maintainer if he has planned to make a Drupal 7 version of the module. To my question, the current maintainer has already replied; for this reason, this report could be closed as fixed.

I had two modules that used the Checkall module, but I removed the code using it because of the absence of a Drupal 7 version.
When I will have time, I will check if I can covert the module for Drupal 7; in that case, I will probably ask to become co-maintainer, once I tested the code.

klonos’s picture

Title: Is it planned to make a release for Drupal 7? » Is it planned to make a release of the Checkall module for Drupal 7?

...sorry Alberto, by "vague" I was referring to the issue's title not mentioning which project it is for. Have you tried how a bunch of "D7 port?" issues for various projects look in your dashboard when they actually don't mention what project they are for?

breos’s picture

StatusFileSize
new4.97 KB

Hello

I have donde a patch for the version 6.x-2.4

Try it and let me know if it works, please

For install the patch:
-Download the 6.x-2.4 Version
-Unzip it and open a console in the unzipped dir
-Copy the patch to the unzipped dir and execute

patch -p1 < checkallportD7.patch

Good luck

avpaderno’s picture

@klonos Well, in few cases the name of the module is added to the issue title; one of those cases is when the issue is about a module being abandoned, or about taking over an existing module. Do you see the word "Drupal" in the title of all the issues opened for Drupal core?

klonos’s picture

@kiamlaluno: go to your Drupal.org dashboard and make sure the "Your posts" block is enabled. Now, subscribe or post something in a few of the hundreds issues about porting modules/themes to D7. Take a look at your dashboard and imagine all of these posts having no specific project name in their title. It would look something like this. Try to figure out to which project they refer to simply by looking at the issue titles.

...having fun with those issues that do not include the project name?

Now, the same thing in the issue queue is entirely different since it includes project names in a separate column of their own.

pfrilling’s picture

Status: Active » Reviewed & tested by the community

I can confirm that breos' patch in comment #9 works.

sunwukong’s picture

why breo's patch does not work for me ...

klonos’s picture

What is not working? What version of the module are you trying to patch? Does the patch apply successfully? If not, did you try applying it manually?

Mihai Chiriac’s picture

StatusFileSize
new21.63 KB

#9 worked for me also.

I've attached the patched module for those who struggle with patching.

mgifford’s picture

Ok, it would be good to get this into a release and close this issue.

Has anyone run it through Coder to do a quick sanity check?

Has anyone reached out to the maintainer? Do they have any concerns? I hope we don't need a new maintainer, but we should be asking that question.

naeluh’s picture

Hey I cannot get this module to work?
Is there supposed to be an option in the field setting with this version?

thanks,

Nick

warmth’s picture

Subscribed!

albert9000’s picture

I'm totally interested in this. I'd like to see this go live.

nolosejoder’s picture

I think one of the errors is in checkall_widget_settings_alter(), that it does not exist in drupal 7 (http://drupal.org/node/982764).

It must be used hook_field_widget_properties_alter (http://api.drupal.org/api/drupal/modules%21field%21field.api.php/functio...)

Any help?

cafuego’s picture

Title: Is it planned to make a release of the Checkall module for Drupal 7? » Drupal 7 port
Version: 6.x-2.x-dev » 7.x-1.x-dev
Category: support » task
Status: Reviewed & tested by the community » Needs work

Okay then! I've taken @markus_petrux up on his offer of co-maintainership.

I created a 7.x-1.x branch in git and started by applying the patch from #9 and manually fixing that up, as it expects to be applied to the 6.x-2.4 release and not the VCS checkout.

The branch does not yet contain a working module. I have the PHP code to the point of showing and storing checkall settings on the field edit form and adding the checkall classes on the entity edit form.

The javascript parts don't work yet (patches welcome! ;-)

warmth’s picture

Great news, keep going! :)

john franklin’s picture

Any progress on the D7 port?

btmash’s picture

I worked on this and the jquery components should be working now. Couple this patch with the code from #2142011: Fix version requirement (module requires >=7.8 core, even if installed is 7.23) and it should all work.

guypaddock’s picture

Status: Needs work » Needs review
StatusFileSize
new6.32 KB

Attached is a better patch against the latest dev (from Jan 2013) that addresses other areas of concern that were causing this not to work in D7.

Namely:

  • The patch in #25 made the $element and $elements parameters pass-by-reference in checkall_form_after_build() and checkall_element_process(). This is not correct -- the functions need to return the element, not modify it in-place.
  • The patch in #25 switched $elements['#entity']->type to $elements['#entity_type'] in checkall_form_after_build(), but both are present in the element. This very same check was also throwing notices on forms like the Modules page because not all controls specify an element type (the default is markup).
  • In the D7 FAPI, [#attributes][class] is an array, not a string.
  • With D7, it is recommended that JavaScript and CSS should be attached to the form elements using [#attached] rather than drupal_add_js() and drupal_add_css().
  • With D7, it is recommended to use the jQuery once() function instead of custom CSS tags to ensure JS attachment is not repeated multiple times on AJAX responses.
  • Since some custom modules and/or themes can hide checkboxes or customize their appearance, and few are listening for changes to the "checked" property on the checkbox, I switched the method used for checking the boxes over to use click() instead of directly manipulating the checked state.
joachim’s picture

StatusFileSize
new6.71 KB

Update to the last patch with one small but critical fix:

-dependencies[] = system >= 7.8
+dependencies[] = system (>7.8)

Without it, it won't enable!

Working fine for me.

frob’s picture

Assigned: Unassigned » frob
Status: Needs review » Needs work

Tested the patch against the latest dev and I cannot turn off the checkall option after I turn it on.

frob’s picture

Priority: Normal » Major
Status: Needs work » Needs review
StatusFileSize
new8.59 KB

That took a bit. It also didn't work with users, and I needed it to. So now it works on more than just nodes.

I am moving the priority up to major, because the module just doesn't work at all on D7 as it is.

frob’s picture

Assigned: frob » Unassigned

I need to unassign myself.

schifazl’s picture

Hello,
I tried #29 without success, the patch didn't even apply, I had to apply a chunk manually. After enabling the module and adding the #checkall property, nothing happens.

schifazl’s picture

Never mind, I've found the setting in the field's edit page, I thought that I had to use the form_alter method. But still the patch needs to be applied manually by copy-paste. Anyway good work!

jweirather’s picture

+1 for RTBC. Downloaded most recent dev version and patch applied cleanly. Configured field as noted (enabled checkall on field instance settings), and the options worked.

If I may recommend to either roll this patch, or add a note/reference to this thread from the main project page.

And thanks for this module!

frob’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs tests

I am marking this as a needs work and needs tests.

This project is supposed to work on the form api level and on the field formatter level. It sounds like we still need to get this to work on the form api level. Some tests might be a good thing moving forward to make sure that this is working on those two levels.

niallmurphy-ie’s picture

After manually applying the patch in #29, the module was working fine but throwing an undefined index: type on line 161 of checkall.module

Before:

    // Append class to the checkboxes items.
    foreach (element_children($element) as $key) {
line 161>    if ($element[$key]['#type'] == 'checkbox') {
        if (!isset($element[$key]['#attributes'])) {
          $element[$key]['#attributes'] = array();
        }
        if (!isset($element[$key]['#attributes']['class'])) {
          $element[$key]['#attributes']['class'] = array();
        }

        $element[$key]['#attributes']['class'][] = $class;
      }
    }

Removing the line and thus the error..

    // Append class to the checkboxes items.
    foreach (element_children($element) as $key) {
     
        if (!isset($element[$key]['#attributes'])) {
          $element[$key]['#attributes'] = array();
        }
        if (!isset($element[$key]['#attributes']['class'])) {
          $element[$key]['#attributes']['class'] = array();
        }

        $element[$key]['#attributes']['class'][] = $class;
      }
    

What does this line do? I've no idea if it's terrible to leave it deleted...

guypaddock’s picture

The line is checking to make sure that it's only applying to checkbox children of a checkboxes form element. (See: https://api.drupal.org/api/drupal/developer%21topics%21forms_api_referen...). Not sure why someone would put other things under a checkboxes element, because they're not likely to be rendered, but it could still happen.

Curious that it would not be set -- the default behavior is usually to convert a checkboxes form element to being a container with checkbox elements inside. Perhaps checkall is getting invoked too early in the form processing?

niallmurphy-ie’s picture

I can't reproduce the error on a clean install so if it's ok to leave it omitted, I'll do that.

I have it working with an entity reference field in an entityform that uses an entity reference view to provide values. I guess something in that muddle is causing the error.

john franklin’s picture

Can we cut what is here as a 7.x-1.0-alpha1 release and start tracking the bugs individually? It sounds like it works for some use cases.

I'm willing to become a co-maintainer if doing so will speed up the release.

cafuego’s picture

@JohnFranklin: Careful what you wish for. No going back now.

john franklin’s picture

Status: Needs work » Fixed

The 7.x-1.0 is out.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.