Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Jun 2006 at 22:02 UTC
Updated:
5 Jul 2010 at 22:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
Robrecht Jacques commentedThe #process seems to propage correctly.
The #tree doesn't.
Tested with module attached where I would expect
#tree => TRUEto be set on the$element, so the output (when submitting) would have$form_values['foo']['part1']instead of currently$form_values['part1'].This bug (?) can be avoided by putting
$element['#tree'] = TRUE;inexpand_mytest().Comment #2
ricabrantes commentedAny news about this? moving to d7.x...
Comment #3
brianV commentedGerhard - is this issue still relevant?
Comment #4
casey commentedYup, #tree => TRUE in hook_element_info() is still not working:
#tree => TRUE is used in system_element_info() for $types['checkboxes'], but #tree => TRUE is also being set in form_process_checkboxes(). When I comment out the latter, #tree functionality on checkboxes is gone.
So it's still not working.
#process in hook_element_info() works fine.
Comment #5
casey commentedComment #6
effulgentsia commentedIf it weren't for the setting of #tree=>TRUE for the 'checkboxes' type in system_element_info(), I'd be tempted to mark this "by design". If we want to make hook_element_info() support #tree, doing so would be easy: within form_builder(), this code:
could be modified to check element_info(), because this code runs for the child element ($element[$key]) before form_builder() is called for that child element, and therefore, defaults haven't been merged in yet.
But I'm not sure supporting #tree in hook_element_info() is a good idea, or at any rate, I'd like a compelling use-case. It seems to me that #tree should be set at the point that child elements are added. Usually, in a form constructor or a #process function. In the example module from #1, I think it makes more sense to set it in the #process function than in hook_element_info(). When is it ever a good idea to set it in hook_element_info()?
Any thoughts on this? If there's agreement that the behavior of HEAD is correct, let's roll a quick patch to remove the unnecessary and misleading line from system_element_info(). If there's a good use-case for letting #tree be specified in hook_element_info(), let's identify it and roll a patch with it as a test.
Comment #7
fagoAgreed. I don't think setting #tree makes sense there except when one uses #process. Then setting it during processing makes imho more sense, as else the constructor could have set it differently already.
Also see #759222: #tree does not default to TRUE, fails to meet developer expectations for fixing nested uses of #tree.
Comment #8
sunThis should be fixed now due to #482816: Make a consistent wrapper around submit buttons
Please confirm that this is still an issue.
Comment #9
sunLet's see what breaks.
Comment #10
effulgentsia commentedHow about this instead? I agree with making it *possible* for hook_element_info() to set #tree, since we also allow hook_element_info() to set #name, #value, and similar properties, that there are few if any good use-cases for doing. But I'm not convinced that we actually want to shift the setting of #tree of checkboxes from the #process function to the hook_element_info() function. If you believe we should, how about arguing for that in a separate issue, and letting this one be just about removing what is probably an unintended exception of what can be done in hook_element_info()?
Comment #11
sunWorks for me :)
Comment #12
effulgentsia commentedThis apparently went in on http://drupal.org/cvs?commit=368076.