fix: [helpers:bootstrap] Table's cell generator gets the correct row index
parent
f18307b3cb
commit
1c81257b75
|
@ -637,13 +637,13 @@ class BoostrapTable extends BootstrapGeneric {
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
foreach ($this->items as $i => $row) {
|
foreach ($this->items as $i => $row) {
|
||||||
$body .= $this->genRow($row);
|
$body .= $this->genRow($row, $i);
|
||||||
}
|
}
|
||||||
$body .= $this->closeNode('tbody');
|
$body .= $this->closeNode('tbody');
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function genRow($row)
|
private function genRow($row, $rowIndex)
|
||||||
{
|
{
|
||||||
$html = $this->openNode('tr',[
|
$html = $this->openNode('tr',[
|
||||||
'class' => [
|
'class' => [
|
||||||
|
@ -658,21 +658,21 @@ class BoostrapTable extends BootstrapGeneric {
|
||||||
$key = $field;
|
$key = $field;
|
||||||
}
|
}
|
||||||
$cellValue = Hash::get($row, $key);
|
$cellValue = Hash::get($row, $key);
|
||||||
$html .= $this->genCell($cellValue, $field, $row, $i);
|
$html .= $this->genCell($cellValue, $field, $row, $rowIndex);
|
||||||
}
|
}
|
||||||
} else { // indexed array
|
} else { // indexed array
|
||||||
foreach ($row as $cellValue) {
|
foreach ($row as $i => $cellValue) {
|
||||||
$html .= $this->genCell($cellValue, $field, $row, $i);
|
$html .= $this->genCell($cellValue, 'index', $row, $rowIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$html .= $this->closeNode('tr');
|
$html .= $this->closeNode('tr');
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function genCell($value, $field=[], $row=[], $i=0)
|
private function genCell($value, $field=[], $row=[], $rowIndex=0)
|
||||||
{
|
{
|
||||||
if (isset($field['formatter'])) {
|
if (isset($field['formatter'])) {
|
||||||
$cellContent = $field['formatter']($value, $row, $i);
|
$cellContent = $field['formatter']($value, $row, $rowIndex);
|
||||||
} else if (isset($field['element'])) {
|
} else if (isset($field['element'])) {
|
||||||
$cellContent = $this->btHelper->getView()->element($field['element'], [
|
$cellContent = $this->btHelper->getView()->element($field['element'], [
|
||||||
'data' => [$value],
|
'data' => [$value],
|
||||||
|
|
Loading…
Reference in New Issue