@@ -687,6 +687,39 @@ their type::
687687 // Upload a file
688688 $form['photo']->upload('/path/to/lucas.jpg');
689689
690+ If you use a :doc: `Collection of Forms </cookbook/form/form_collections >`,
691+ you can't add fields to the existing form (this results in an error
692+ ``Unreachable field "…" ``). You can use the `submitWithAdditionalValues() `
693+ method in order to add new fields::
694+
695+ $crawler = $client->submitWithAdditionalValues(
696+ $form,
697+ array(),
698+ // New values:
699+ array('task[tags][0][name]' => 'tag1'),
700+ );
701+
702+ // The tag has been added.
703+ $this->assertEquals(1, $crawler->filter('ul.tags > li')->count());
704+
705+ Where ``task[tags][0][name] `` is the name of a field usually created
706+ with Javascript.
707+
708+ You can remove an existing field, e.g. a tag::
709+
710+ // Get the values of the form.
711+ $values = $form->getPhpValues();
712+
713+ // Remove the first tag.
714+ unset($values['task']['tags'][0]);
715+
716+ // Submit the data.
717+ $crawler = $client->request($form->getMethod(), $form->getUri(),
718+ $values, $form->getPhpFiles());
719+
720+ // The tag has been removed.
721+ $this->assertEquals(0, $crawler->filter('ul.tags > li')->count());
722+
690723.. tip ::
691724
692725 If you purposefully want to select "invalid" select/radio values, see
0 commit comments