Skip to content

Commit

Permalink
DEBUG with SQL expr
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Oct 13, 2022
1 parent db026d0 commit fbdc43f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 11 additions & 2 deletions demos/form-control/multiline.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,28 @@ protected function init(): void
]);
$this->addExpression('total', [
'expr' => function (Model $row) {
return $row->get('qty') * $row->get('box');
return $row->expr('[qty] * [box]'); // @phpstan-ignore-line
},
'type' => 'integer',
'ui' => ['multiline' => [Form\Control\Multiline::TABLE_CELL => ['width' => 1, 'class' => 'blue']]],
]);
}
});

$inventory = new $inventoryItemClass(new Persistence\Array_(), ['countryPersistence' => $app->db]);
$inventory = new $inventoryItemClass($app->db, ['table' => 'atk4_ui_multiline_test', 'countryPersistence' => $app->db]);

$migrator = new \Atk4\Data\Schema\Migrator($inventory);
if (!$migrator->isTableExists($inventory->table)) {
$migrator->create();
}

// Populate some data.
$total = 0;
for ($i = 1; $i < 3; ++$i) {
if ($inventory->tryLoad($i) !== null) {
continue;
}

$entity = $inventory->createEntity();
$entity->set('id', $i);
$entity->set('inv_date', new \DateTime());
Expand Down
7 changes: 7 additions & 0 deletions tests-behat/multiline.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Multiline

Scenario:
Given I am on "form-control/multiline.php"
When I fill in "-box" with "3693"
Then I press button "Save"
Then Toast display should contain text '"box": 3693,'

0 comments on commit fbdc43f

Please sign in to comment.