When I try to use tableselect type in hook_view() function I've got following PHP message:
Notice: Undefined index: #attributes in theme_tableselect() (line 2802 of /var/www/drupal7/includes/form.inc).
// some code: I prepared $header and $options, etc...
$node->content['something'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No data available.'),
'#weigth' => 10
);
return $node;
Html table has been displayed correctly, but #attributes key should be optional.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | Notice-Undefined-index-877674-12.patch | 579 bytes | jyotisankar |
| #1 | 877674-attributs-optional.patch | 739 bytes | aspilicious |
Comments
Comment #1
aspilicious commentedThis should work, didn't test it.
Comment #2
ryan.armstrong commentedGot the same error and can confirm that this patch does indeed fix it. Is this something that cannot be put into 7 (Referring to the change from 7.x to 8.x)?
Comment #3
heine commentedtableselect is a form element. Are form elements supposed to magically work in other render arrays?
Comment #4
damien tournoud commentedNo, they are not (and most of them don't), but I think we should try.
In that case, the proper fix would probably be to add #attributes as a default for 'tableselect' in system_elements().
Comment #5
john.doe commentedit's seem mistake : and prefore solve method is not work, how can deal with it. give me a idea.
if i follow the step , but it is not work.
Comment #6
heine commentedTo #5, I don't understand what you want.
Comment #7
rob c commentedThe patch in #1 also works for D7.14.
Comment #10
alansaviolobo commentedComment #11
lokapujyaIn D8, the table doesn't render from a render array (and the notice is not created.) The table only renders in a form.
Comment #12
jyotisankar commentedComment #13
David Hernández commentedHello!
Thank you for working on this issue!
We should all try and use the same sprint tag. According to https://groups.drupal.org/node/447258 it should be SprintWeekend2015 with no #.