diff --git a/demos/form-control/multiline.php b/demos/form-control/multiline.php index 399cb50ab0..d5a605c9f1 100644 --- a/demos/form-control/multiline.php +++ b/demos/form-control/multiline.php @@ -60,7 +60,7 @@ 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']]], @@ -68,11 +68,20 @@ protected function init(): void } }); -$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()); diff --git a/tests-behat/multiline.feature b/tests-behat/multiline.feature new file mode 100644 index 0000000000..178b21b6a3 --- /dev/null +++ b/tests-behat/multiline.feature @@ -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,'