The $fields variable is undefined causing the field name class "views-field-<FIELD_NAME>" to be missing.

See attachment for a suggested fix.

Comments

geneticdrift’s picture

Status: Active » Needs review
creeksideplayers’s picture

The table headers also missing class information. All the table headers are coming up with a class of "views-field-v". This has broken the formatting on my site where I set the column widths based on the class names. I applied the patch, and I also made this change the "th" lines from this:

<th class="views-field views-field-<?php print $class[$key] ?>"><?php print $value ?></th>

to this:

<th class="views-field views-field-<?php print $key ?>"><?php print $value ?></th>
bojanz’s picture

@geneticdrift @hsvmda
Which Views versions are you using?

I'm guessing something is wrong with the way VBO calls the template file, if $fields is undefined.
Might be something about Views 2 <> Views 3 (VBO tries to support both branches, which is generally a bad idea).

geneticdrift’s picture

Using views version 6.x-2.12

creeksideplayers’s picture

@bojanz - I'm using Views 6.x-2.12

todd nienkerk’s picture

I can also confirm this in Views 6.x-2.12.

ryan_courtnage’s picture

Confirmed - Views 6.x-2.12

ryan_courtnage’s picture

FYI, i don't think that the OP's patch is the right fix. In 6.x-1.10, the class for a row would have looked like (for example):

class="views-field views-field-edit-node"

With the OP's patch, it will look like:

class="views-field views-field-edit_node"

The bug is likely be in the preprocess function and not the tpl.

ryan_courtnage’s picture

StatusFileSize
new1.64 KB

I do believe that the attached is the correct fix for this issue. Basically, we need to build $vars['fields'] appropriately in the preprocess. As well, we need to apply the 'active' class to the column being sorted.

Can someone using Views 3 confirm if the VBO table classes are applied properly?

bojanz’s picture

Title: In views-bulk-operations-table.tpl.php undefined variable $fields » VBO table doesn't have correct classes on td and th elements
Status: Needs review » Fixed

ryan_courtnage, you're a rock star :)
Confirmed that it works with Views 3. Committed. Thanks!

creeksideplayers’s picture

Thanks, bojanz. That works a lot better, but there is still a problem with the table data for the select column:

<td class="views-field ">

I've added this to the for loop in views-bulk-operations-table.tpl.php that outputs the table data:

<?php if ($field == 'select') { ?>
  <td class="views-field select">
<?php } else { ?>
  <td class="views-field <?php if (!empty($fields[$field])) print "views-field-{$fields[$field]}"; ?>">
<?php } ?>
bojanz’s picture

Status: Fixed » Needs review

I wasn't sure whether we needed a class there. But sure. Setting to "needs review" for now, and I'll take a look later.

bojanz’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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