Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage of getFields() and fix Card #892

Merged
merged 3 commits into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/ActionExecutor/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ public function initPreview()
*/
protected function getModelFields(Model $model)
{
$fields = [];
foreach ($model->getFields() as $f) {
if ($f->isEditable() || $f->isVisible()) {
$fields[] = $f->short_name;
}
}

return $fields;
return array_keys($model->getFields(['editable', 'visible']));
}
}
2 changes: 1 addition & 1 deletion src/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function setModel(Model $m, $fields = null)
}

if (!$fields) {
$fields = array_keys($this->model->getFields('visible'));
$fields = array_keys($this->model->getFields(['editable', 'visible']));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarkSide666 - Why do we need to restrict display of field value to editable fields in Card? What if a non editable field needs to be display? Will that prevent it to show in Card?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It now will show not only visible fields but also editable fields (but will of course not allow to edit them because it's just a readonly card view).
Otherwise currently it only shows visible fields, but if we have some field which we don't want to show in Grid as column (not visible), but show in form (is editable), then in Card view these fields was not visible and i think in case of card view it's wrong (for example for mastercrud which uses card view).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok make sense.

}

$this->setDataId($this->model->get($this->model->id_field));
Expand Down
2 changes: 1 addition & 1 deletion src/CardSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function addDescription($description)
{
$view = null;

if (is_string($description)) {
if (is_scalar($description)) {
$view = $this->add(new View([$description, 'class' => ['description']]));
} elseif ($description instanceof View) {
$view = $this->add($description)->addClass('description');
Expand Down