Priority: Normal
Current State: Closed
Released In: 1.1.9
Target Release: patch
Applies To: Engine
Component: FoswikiForm
Branches: Release01x01
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 .= ' ';
$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