symfony-console-form icon indicating copy to clipboard operation
symfony-console-form copied to clipboard

Don't cast form->data to array if it's not iterable

Open oleg-andreyev opened this issue 4 years ago • 3 comments

  • Form Data may be not iterable, so need to throw an exception if data is not iterable
  • When working with ArrayCollection it's already iterable, so need to cast to array

oleg-andreyev avatar Nov 20 '20 19:11 oleg-andreyev

Thanks for making this PR. What's missing for me is a test case that shows when this is indeed a problem. I understand why you need this, but I want to ensure that the feature "this library works with iterables in general" also keeps working in the future, etc. So can you take a look at the tests and add a form type that shows how you're using a form field with a collection? Feel free to add doctrine/collections as a dev dependency, so you can mimic a real-world scenario.

matthiasnoback avatar Nov 21 '20 16:11 matthiasnoback

@matthiasnoback added a test case.

oleg-andreyev avatar Nov 26 '20 19:11 oleg-andreyev

Sorry, I merged the other PR first. Can you take a look at the tests and make them pass?

matthiasnoback avatar Nov 28 '20 12:11 matthiasnoback