Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Jun 2010 at 21:42 UTC
Updated:
4 Nov 2010 at 20:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
heine commentedPatch is offcourse completely broken when #multiple is FALSE, needs #multiple check, but that's work for another day.
Comment #2
heine commentedComment #3
heine commentedsolotandem remarked that this changes behaviour:
before
with patch:
I like the change better for it is inline with checkboxes, but that should be discussed separately.
Comment #4
heine commentedso the latest patch changes the behaviour back.
Comment #5
solotandem commentedI prefer the values in the default_values array over the keys in that array. This goes along with patch in #2. I was simply pointing out this is different from what it was doing and was not aware if it was intended to use the keys or the values. Seems more intuitive to use the values.
Comment #7
solotandem commentedAttached patch:
- incorporates multiple value check in form_type_tableselect_value()
- includes type = tableselect in processing done for checkboxes in drupal_process_form()
- modifies tests when not multiple value
Comment #8
solotandem commentedComment #9
solotandem commentedRevised patch:
- handles the form code defining default values and the user clearing the default values (and not checking any other values)
- defines the defaults in the same way as the checkboxes element (i.e. the array value not the key)
Comment #10
solotandem commentedHere is a simpler version of the previous patch that simply calls the form_type_checkboxes_value() function.
Comment #11
heine commentedI'm - in principle - in favor of changing the arguments to make them consistent with checkboxes, but this late in the release cycle? Also, shouldn't this need changes to tableselect usage in core?
Comment #12
solotandem commentedThe only change with using the checkboxes code is if the core code sets the #default_value property on a tableselect item. The only occurrence of this seems to be in node.admin.inc with '#default_value' => array(1 => 1, 2 => 2). Thus, whether keys or values are used to set the value, should it not work the same?
Interestingly, this issue highlights a missing facet to the test for the tableselect widget (and possibly others). None of the tableselect tests set a default value, tested for it, changed it and tested again, etc.
Comment #13
heine commentedHaving to use
instead of the checkboxes-like
was a really stupid decision (by me).
I'd love to get the change in as an API fix.
Apart from the API fix, patch restores the ability to uncheck boxes set with default_value. I was unable to send tampered values or keys with the patch from #10 applied.
I'd remove the noop else. Without that clause, I would mark this RTBC for a core committer to remark on the API change.
Comment #14
solotandem commentedRerolled with suggestions in IRC from Heine.
Comment #16
solotandem commentedComment #17
solotandem commentedComment #18
solotandem commentedMarking RTBC per Heine's comment in #13 as latest patch incorporates the conditions he stated for changing to RTBC.
Comment #19
heine commentedTo quote the branch maintainer:
So, that leaves us with the patch from #3; it works fine, except that the tests no longer properly test the behaviour. They could simply be removed.
Comment #20
solotandem commentedI downloaded and grepped all the D7 contributed modules on drupal.org for 'tableselect.' Only one other module (besides coder upgrade) sets a default value for this form element. Thus, to change the default value handling (or more accurately to conform it to checkboxes), does not appear to affect a significant base of existing code. We can inform the maintainer of the other module of this change. Also, as mentioned above, there is no instance in core of setting the default value for this form element.
This seems like a "no brainer" to commit.
Comment #21
solotandem commentedRerolled patch from #3 with a comment for D8 and one additional line change in _form_validate().
Comment #22
sunNot sure why we document the callback params and return values all over again. I'd be happy to not introduce them here.
(The phpDoc is the same for all form element value callbacks.)
Leaving that decision to you.
Please remove that code. It's nice that you think ahead of time, but D8 may turn out to be entirely different, so the entire commented out code might be moot.
I guess a #type tableselect cannot be non-multiple? Otherwise, we'd be dealing with a serious abuse of the element, and I'd make a call to not support that.
Hence, let's just drop this extra condition.
Powered by Dreditor.
Comment #23
solotandem commentedThanks for looking at this. Responding to your points:
I left the callback parameters as it seems odd to remove them only from one value callback. It would seem another issue should be created to modify all of the callbacks to remove the redundant parameters and add an @see reference to the documentation of the parameters.
Removed the D8 comment and code.
Retained the "$element['#multiple']" condition because this value can be FALSE. If it is, radio buttons are displayed and the default value handling is used.
Attached patch is against current HEAD.
Comment #24
sunPlease also add this important detail to the inline comment, slightly reworded.
Comment #25
solotandem commentedRevised as suggested above.
Comment #26
solotandem commentedRerolled against current HEAD.
Comment #27
boombatower commentedComment #28
solotandem commented#26: 831966-core-tableselect.patch queued for re-testing.
Comment #29
webchickCommitted to HEAD.