mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #6468 from cakephp/2.7-html-table-cell
Fix tableCells()
This commit is contained in:
commit
ca768399bd
2 changed files with 24 additions and 2 deletions
|
@ -1926,6 +1926,21 @@ class HtmlHelperTest extends CakeTestCase {
|
||||||
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false);
|
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false);
|
||||||
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
|
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
|
||||||
$this->assertEquals($expected, $result);
|
$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(
|
||||||
|
'<tr',
|
||||||
|
array('td' => 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -901,9 +901,16 @@ class HtmlHelper extends AppHelper {
|
||||||
if (is_array($cell)) {
|
if (is_array($cell)) {
|
||||||
$cellOptions = $cell[1];
|
$cellOptions = $cell[1];
|
||||||
$cell = $cell[0];
|
$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);
|
$cellsOut[] = sprintf($this->_tags['tablecell'], $this->_parseAttributes($cellOptions), $cell);
|
||||||
}
|
}
|
||||||
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
|
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
|
||||||
|
|
Loading…
Reference in a new issue