Download & Extend

theme_tableselect() example code crashes

Project:Drupal core
Version:8.x-dev
Component:documentation
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:needs backport to D7, Novice

Issue Summary

API page: http://api.drupal.org/api/drupal/includes!form.inc/function/theme_tableselect/7

Enter a descriptive title (above) relating to theme_tableselect, then describe the problem you have found:

This is missing some ; and ,

Comments

#1

The code is also wrong... in that the table produced is empty because there is no #header property.

Perhaps I should remove the Novice tag...?

#2

Status:active» needs review

I am a novice, but I'll have a go ;) How about something like this?

AttachmentSizeStatusTest resultOperations
form-codeexample-1706926-2.patch1.22 KBIdlePASSED: [[SimpleTest]]: [MySQL] 39,799 pass(es).View details

#3

Status:needs review» needs work

Thanks! This is a good start... Someone needs to test the code to verify that it actually works now.

Also, I would prefer to see a code style more like:

$options = array(
  array (
   'object' => 'Treacle',
   'colour' => 'brown',
   '#attributes' => array ('class' => array('brown-row')),
),
...

(that would be more consistent with what we normally do in Drupal Core).

Please also use the American spelling "color" instead of "colour". And we don't normally leave a space between array and the opening (.

#4

Status:needs work» needs review

Thanks for the review jhodgdon. Here's another patch incorporating your suggestions.

AttachmentSizeStatusTest resultOperations
form-codeexample-1706926-4.patch1.24 KBIdlePASSED: [[SimpleTest]]: [MySQL] 39,980 pass(es).View details

#5

Looks pretty good, formatting-wise anyway... Someone needs to test the code and verify that it works.

Also, doesn't this need a t() on the title and empty text?

+ *   '#title' => 'Table Select',
+ *   '#header' => $header,
+ *   '#options' => $options,
+ *   '#empty' => 'Nothing to show',

#6

I have rerolled the patch with a few updates thanks to jhodgdon and I tested the code.

  1. Wrapped #empty with the t() function
  2. Removed #title as it's not used on the tableselect element, API.
AttachmentSizeStatusTest resultOperations
form-codeexample-1706926-6.patch1.21 KBIdlePASSED: [[SimpleTest]]: [MySQL] 40,571 pass(es).View details

#7

Status:needs review» needs work

Better!

I guess I must not have looked too carefully at the formatting on the previous patch. I think there are a couple of things that need fixing here:
- array(...) should not have a space between array and (
- I think we could do away with all of the blank lines in the code sample. They take up a lot of space and I don't think they add a lot of clarity.

I am also confused about this example. This is a table-select... maybe we could use something that is more realistic? What is this treacle and corkscrew meant to be? I don't even think most people in the world would know what "treacle" is -- I'm not really sure myself. Also, what is the empty text meant to be saying?

#8

Thanks for the review jhodgdon. I have implemented the requested changes.

- Fixed up the spacing issue between array and (
- Cleaned up the white spaces
- Made the content a bit more realistic

AttachmentSizeStatusTest resultOperations
form-codeexample-1706926-8.patch1.33 KBIdlePASSED: [[SimpleTest]]: [MySQL] 40,573 pass(es).View details

#9

Status:needs work» needs review

#10

Status:needs review» needs work

Much better, thanks! I was about to commit this patch, but I realized it pertains to the @param, so it should be included in the @param instead of where it is now in the main body of the function docs (which doesn't make much sense, since it lacks context).

#11

Status:needs work» needs review

Yes that does make sense. I have moved the @code below the @param.

AttachmentSizeStatusTest resultOperations
form-codeexample-1706926-11.patch1.91 KBIdlePASSED: [[SimpleTest]]: [MySQL] 40,706 pass(es).View details

#12

Status:needs review» needs work

The last submitted patch, form-codeexample-1706926-11.patch, failed testing.

#13

Status:needs work» needs review

#11: form-codeexample-1706926-11.patch queued for re-testing.

#14

Status:needs review» needs work

The blank line between the existing @param text and the new text needs to be removed, and the new text should be wrapped with the previous text. Thanks!

#15

Status:needs work» needs review

Here's another patch with the requested changes.

AttachmentSizeStatusTest resultOperations
form-codeexample-1706926-15.patch1.99 KBIdlePASSED: [[SimpleTest]]: [MySQL] 40,704 pass(es).View details

#16

Status:needs review» needs work

Thanks! The only thing is, these two lines should be wrapped together:

*     table row's HTML attributes; see theme_table().
+ *     An example of per-row options:

#17

Status:needs work» needs review

Sorry about that, I have wrapped the text onto a single line:

*     table row's HTML attributes; see theme_table(). An example of per-row options:
*     @code
AttachmentSizeStatusTest resultOperations
form-codeexample-1706926-17.patch2.12 KBIdlePASSED: [[SimpleTest]]: [MySQL] 40,734 pass(es).View details

#18

Status:needs review» reviewed & tested by the community

Looks good! I'll get this committed shortly.

#19

Status:reviewed & tested by the community» needs work

Actually, that line needs to be wrapped at 80 characters. It goes over by a few currently.

#20

Status:needs work» needs review

Re-rolled the patch and wrapped the line at 80 characters.

AttachmentSizeStatusTest resultOperations
form-codeexample-1706926-20.patch2.12 KBIdlePASSED: [[SimpleTest]]: [MySQL] 40,746 pass(es).View details

#21

Status:needs review» reviewed & tested by the community

This time I think I'll be able to commit it. Thanks!

#22

Status:reviewed & tested by the community» fixed

Thanks! Committed to 8.x and 7.x.

#23

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here