Skip to content

Commit e046779

Browse files
committed
POC of value /w entity link
1 parent 3709c3c commit e046779

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

src/CardTable.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,18 @@ public function setModel(Model $model, array $columns = null): void
3434
}
3535

3636
$data = [];
37-
foreach ($model->get() as $key => $value) {
38-
if (in_array($key, $columns, true)) {
37+
foreach (array_keys($model->get()) as $fieldName) {
38+
if (in_array($fieldName, $columns, true)) {
3939
$data[] = [
40-
'id' => $key,
41-
'field' => $model->getField($key)->getCaption(),
42-
'value' => $this->getApp()->uiPersistence->typecastSaveField($model->getField($key), $value),
40+
'id' => $fieldName,
41+
'field' => $model->getField($fieldName)->getCaption(),
42+
'value' => new Model\EntityFieldPair($model, $fieldName),
4343
];
4444
}
4545
}
4646

4747
$this->_bypass = true;
48-
$mm = parent::setSource($data);
49-
$this->addDecorator('value', [Table\Column\Multiformat::class, function (Model $row, $field) use ($model) {
50-
$field = $model->getField($row->getId());
51-
$ret = $this->decoratorFactory(
52-
$field,
53-
$field->type === 'boolean' ? [Table\Column\Status::class, ['positive' => [true, 'Yes'], 'negative' => [false, 'No']]] : []
54-
);
55-
if ($ret instanceof Table\Column\Money) {
56-
$ret->attr['all']['class'] = ['single line'];
57-
}
58-
59-
return [$ret];
60-
}]);
48+
parent::setSource($data);
6149
$this->_bypass = false;
6250
}
6351
}

0 commit comments

Comments
 (0)