Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

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...?

eddie_c’s picture

Status: Active » Needs review
FileSize
1.22 KB

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

jhodgdon’s picture

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 (.

eddie_c’s picture

Status: Needs work » Needs review
FileSize
1.24 KB

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

jhodgdon’s picture

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',
Ivan Zugec’s picture

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.
jhodgdon’s picture

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?

Ivan Zugec’s picture

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

Ivan Zugec’s picture

Status: Needs work » Needs review
jhodgdon’s picture

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).

Ivan Zugec’s picture

Status: Needs work » Needs review
FileSize
1.91 KB

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

Status: Needs review » Needs work
Issue tags: -Novice, -Needs backport to D7

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

jhodgdon’s picture

Status: Needs work » Needs review
Issue tags: +Novice, +Needs backport to D7

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

jhodgdon’s picture

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!

Ivan Zugec’s picture

Status: Needs work » Needs review
FileSize
1.99 KB

Here's another patch with the requested changes.

jhodgdon’s picture

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:
Ivan Zugec’s picture

Status: Needs work » Needs review
FileSize
2.12 KB

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
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good! I'll get this committed shortly.

jhodgdon’s picture

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.

Ivan Zugec’s picture

Status: Needs work » Needs review
FileSize
2.12 KB

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

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

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

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

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

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