symfony/symfony — pull request #4574 by shiroyuki (2012-06-14 07:11:05+00:00)
Title: Dynamic field

This PR is to address when in the following scenario.

Supposed the following `Post` class is a part of a blog software which can freely add or remove tags.

```php
// A sample code with all annotations omitted and coding standard ignored
// Suppose that we have Tag.
class Post {
// Omit unrelated to the illustration.

/* @var ArrayCollection a collection of Tag */
protected $tags;
}
```

Then, suppose we have a form type for it.

Now as there is a case that a post might not have tags when the form is first rendered, there are no input fields for tags. In this case, when we write the functional test for the controller using this form type, if we want to simulate the case that JavaScript dynamically generates form fields to handle new tags, then the `DomCrawler\Form` will always throw an exception as it cannot find the form fields for the new tags or any tags that aren't rendered by PHP.

Hence, in order to allow developers to test, the PR will allow the form to dynamically generate form fields if any of them is submitted if needed by calling `$form->enableDynamicField(true)` to enable this feature or `$form->enableDynamicField(false)` to disable it (where `$form` is an instance of type `Symfony\Component\DomCrawler\Form`).