Skip to content

Commit

Permalink
POC of value /w entity link
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Aug 28, 2022
1 parent ec6ac94 commit be26736
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/CardTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,18 @@ public function setModel(Model $model, array $columns = null): void
}

$data = [];
foreach ($model->get() as $key => $value) {
if (in_array($key, $columns, true)) {
foreach (array_keys($model->get()) as $fieldName) {
if (in_array($fieldName, $columns, true)) {
$data[] = [
'id' => $key,
'field' => $model->getField($key)->getCaption(),
'value' => $this->getApp()->uiPersistence->typecastSaveField($model->getField($key), $value),
'id' => $fieldName,
'field' => $model->getField($fieldName)->getCaption(),
'value' => new Model\EntityFieldPair($model, $fieldName),
];
}
}

$this->_bypass = true;
$mm = parent::setSource($data);
$this->addDecorator('value', [Table\Column\Multiformat::class, function (Model $row, $field) use ($model) {
$field = $model->getField($row->getId());
$ret = $this->decoratorFactory(
$field,
$field->type === 'boolean' ? [Table\Column\Status::class, ['positive' => [true, 'Yes'], 'negative' => [false, 'No']]] : []
);
if ($ret instanceof Table\Column\Money) {
$ret->attr['all']['class'] = ['single line'];
}

return [$ret];
}]);
parent::setSource($data);
$this->_bypass = false;
}
}

0 comments on commit be26736

Please sign in to comment.