You are here: Foswiki>Tasks Web>Item12064 (19 Nov 2013, GeorgeClark)Edit Attach

Item12064: In data forms, buttons "Set all" and "Clear all" do nothing when clicked.

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.9
Target Release: patch
Applies To: Engine
Component: FoswikiForm
Branches: Release01x01
Reported By: ColasNahaboo
Waiting For:
Last Change By: GeorgeClark
In data forms, buttons "Set all" and "Clear all" do nothing when clicked.

It seems that they call the javascript function checkAll defined in /pub/System/JavascriptFiles/foswiki_renamebase.js but this function seems coded in a non-general way: it seems to only work with checkboxes named "referring_topics":

function checkAll(inForm, inState) {
	// find button element index
	if (inForm == undefined) return;
	var i, j = 0;
	for (i = 0; i < inForm.length; ++i) {
		if (inForm.elements[i].name.match("referring_topics")) {
			inForm.elements[i].checked = inState;
		}
	}
}

I guess the fix should be either to make checkAll really generic, and be moved in the common js files, or have the ...Form.js code augmented with a generic checkAll function

I stumbled upon the bug in 1.0.9, but it is still in 1.1.5, you can test it on forwiki.org here: http://foswiki.org/Sandbox/TestCheckboxPlusButtonsForm
  • edit the topic (or just edit the form)
  • click the Set all button. nothing happens.

-- ColasNahaboo - 30 Aug 2012

This is a core bug and not related to FormsAddOn, or NatEditPlugin as reported in Item12603

-- MichaelDaum - 16 Oct 2013

Try this hotfix:

--- lib/Foswiki/Form/Checkbox.pm        (revision 16922)
+++ lib/Foswiki/Form/Checkbox.pm        (working copy)
@@ -107,15 +107,15 @@
         my $boxes = scalar( @{ $this->getOptions() } );
         $extra = CGI::br();
         $extra .= CGI::button(
-            -class   => 'foswikiCheckbox',
+            -class   => 'foswikiButton',
             -value   => $session->i18n->maketext('Set all'),
-            -onClick => 'checkAll(this,2,' . $boxes . ',true)'
+            -onClick => 'jQuery(this).parents("form").find("input[name='.$this->{name}.']").prop("checked", true);',
         );
         $extra .= '&nbsp;';
         $extra .= CGI::button(
-            -class   => 'foswikiCheckbox',
+            -class   => 'foswikiButton',
             -value   => $session->i18n->maketext('Clear all'),
-            -onClick => 'checkAll(this,1,' . $boxes . ',false)'
+            -onClick => 'jQuery(this).parents("form").find("input[name='.$this->{name}.']").prop("checked", false);',
         );
     }
     $value = '' unless defined($value) && length($value);

-- MichaelDaum - 16 Oct 2013
 
Topic revision: r8 - 19 Nov 2013, GeorgeClark - This page was cached on 01 Oct 2016 - 03:29.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License