diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
index 873f6a955..5de351701 100644
--- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
+++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
@@ -1926,6 +1926,21 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false);
$expected = "
td content 1 | td content 2 | td content 3 |
\ntd content 1 | td content 2 | td content 3 |
\ntd content 1 | td content 2 | td content 3 |
";
$this->assertEquals($expected, $result);
+
+ $tr = array(
+ 'td content 1',
+ 'td content 2',
+ array('td content 3', array('class' => 'foo'))
+ );
+ $result = $this->Html->tableCells($tr, null, null, true);
+ $expected = array(
+ ' array('class' => 'column-1')), 'td content 1', '/td',
+ array('td' => array('class' => 'column-2')), 'td content 2', '/td',
+ array('td' => array('class' => 'foo column-3')), 'td content 3', '/td',
+ '/tr'
+ );
+ $this->assertTags($result, $expected);
}
/**
diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php
index adb6220d5..9f5409446 100644
--- a/lib/Cake/View/Helper/HtmlHelper.php
+++ b/lib/Cake/View/Helper/HtmlHelper.php
@@ -901,9 +901,16 @@ class HtmlHelper extends AppHelper {
if (is_array($cell)) {
$cellOptions = $cell[1];
$cell = $cell[0];
- } elseif ($useCount) {
- $cellOptions['class'] = 'column-' . ++$i;
}
+
+ if ($useCount) {
+ if (isset($cellOptions['class'])) {
+ $cellOptions['class'] .= ' column-' . ++$i;
+ } else {
+ $cellOptions['class'] = 'column-' . ++$i;
+ }
+ }
+
$cellsOut[] = sprintf($this->_tags['tablecell'], $this->_parseAttributes($cellOptions), $cell);
}
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);