forms-multiplier icon indicating copy to clipboard operation
forms-multiplier copied to clipboard

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

Open jtojnar opened this issue 3 months ago • 0 comments

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.

  • [x] Add test reproducing #68 or #79.

jtojnar avatar Mar 21 '24 00:03 jtojnar