contributte / forms-multiplier

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

Remove addCopy() when removeAction #34

Closed kravcik closed 5 years ago

kravcik commented 5 years ago
  1. create-project nette/web-project nette-blog
  2. composer require webchemistry/forms-multiplier
  3. Create form via readme example (https://github.com/WebChemistry/forms-multiplier#usage)
  4. Containers cannot be removed (always copied back)
  5. With this ugly change its working well

Code-review maybe required - Foreach for FilterCallbackIterator should be replaced with some "findContainerById()".

kravcik commented 5 years ago

Test failing doesnt make sense for me. Dom structure seems ok, but why callback throw ->fail();?

MartkCz commented 5 years ago

If you want to delete last element, can you try set minCopies to zero?

$multiplier->setMinCopies(0);

https://github.com/WebChemistry/forms-multiplier/blob/master/src/Multiplier.php#L81

I must refactor whole component... I'll check it out

kravcik commented 5 years ago

Maybe GIF would be better than my rusty english. :) bdump($_POST). With this PR bug doesnt apper.

test

MartkCz commented 5 years ago

Thank you for excellent demonstration. Did you try @dev version? I release v3.0.4 only 4 hours ago :/

kravcik commented 5 years ago

Master (or v3.0.4) has same problems.

MartkCz commented 5 years ago

Oh, you are using Nette\Forms\Form instead of Nette\Application\UI\Form... it's my bad, I hope I found simpler fix https://github.com/WebChemistry/forms-multiplier/commit/97b557706065dd8258dfa9c6db7a0ffe2ef7534a

kravcik commented 5 years ago

This commit works like a charm! Thank you.

PR is obsolete then.