contributte / forms-multiplier

:repeat: Form multiplier & replicator for Nette Framework
https://contributte.org/packages/contributte/forms-multiplier.html
MIT License
26 stars 20 forks source link

Multiplier::validate(): Filter out non-validatable components #103

Open jtojnar opened 4 months ago

jtojnar commented 4 months ago

45ed76a7ed22c9b97048441eccd4a7fb2f8f2d6f started filtering components to Controls, to appease PHPStan, since Container::validate() only accepts Control[]. But Multiplier does not actually have Controls as direct children (other than the ‘Add’ Submitters), so it would stop validating and filtering multiplied controls.

a5a7348fdb1046275e83fa47d73a444695cf21b4 reverted that part but kept the incorrect phpdoc type cast.

Now, it works without the filter because Container::validate() already ignores non-validatable components but we should still respect its contract.

Let’s filter the components before passing them down. This will also allow us to drop the lying phpdoc type cast.

Depends on https://github.com/nette/forms/pull/323 for PHPStan to pass.

jtojnar commented 2 months ago

The PHPStan issue is caused by https://github.com/phpstan/phpstan-nette/issues/141