Skip to content
Open
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"contributte/qa": "~0.4.0",
"contributte/tester": "~0.4.0",
"latte/latte": "^3.0.0",
"nette/application": "^3.2.0",
"nette/application": ">=3.2.0 <3.3.0",
"nette/di": "^3.2.0",
"webchemistry/testing-helpers": "^4.0.0"
"webchemistry/testing-helpers": "^4.1.1"
},
"conflict": {
"latte/latte": "<3.0.0",
Expand Down
6 changes: 5 additions & 1 deletion src/Multiplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Contributte\FormMultiplier\Buttons\CreateButton;
use Contributte\FormMultiplier\Buttons\RemoveButton;
use Generator;
use Iterator;
use Nette\ComponentModel\IComponent;
use Nette\Forms\Container;
Expand Down Expand Up @@ -306,8 +307,11 @@ public function getValues(string|object|bool|null $returnType = null, ?array $co
public function getControls(): Iterator
{
$this->createCopies();
$controls = parent::getControls();

return parent::getControls();
return (static function () use ($controls): Generator {
yield from $controls;
})();
Comment on lines +312 to +314

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just:

Suggested change
return (static function () use ($controls): Generator {
yield from $controls;
})();
yield from $controls;

}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/Cases/Unit/MultiplierTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Tests\Cases\Unit;

use Contributte\FormMultiplier\Multiplier;
use Contributte\Tester\Toolkit;
use Iterator;
use Nette\Application\UI\Form;
use Nette\Forms\Container;
use Tester\Assert;
Expand All @@ -15,6 +16,13 @@ require __DIR__ . '/../../bootstrap.php';

$services = new Services();

// testGetControlsReturnsIterator
Toolkit::test(function (): void {
$form = MultiplierBuilder::create()->createForm();

Assert::type(Iterator::class, $form['m']->getControls());
});

// testRenderBase
Toolkit::test(function () use ($services): void {
$onCreateParams = [];
Expand Down