Join GitHub today
Functional Testing Collection Form Fields #4124
In the following example, Office has a many-to-many with Contact.
When attempting the same approach in functional tests, e.g. by doing:
$form = $buttonCrawlerNode->form(array( 'company_whateverbundle_officetype[office_contacts][contact]' => '1' ));
The actual result is:
The expected result is that a new contact is added.
Steps to reproduce:
I was facing this problem to today, I actually needed to remove a row from the collection
But found I little trick to make this work.
$form = $crawler->selectButton('save')->form(); $form->setValues(array( 'customer_invoice_form[customer]' => 'C0001', 'customer_invoice_form[address]' => "274 Rose avenue US\n212-35 OKMontgomery", 'customer_invoice_form[items][number]' => 1, 'customer_invoice_form[items][label]' => 'Domainreg bar-foo.com', 'customer_invoice_form[items][period][start]' => '01-01-2013', 'customer_invoice_form[items][period][end]' => '01-12-2013', 'customer_invoice_form[items][price]' => '20,00', 'customer_invoice_form[items][taxPercent]' => '21,10', )); // Now do what ever you want with the $values. $values = $form->getPhpValues(); unset($values['customer_invoice_form']['items']); $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles()); //$client->submit($form);
Ok, here's another workaround:
changed the title from
[Form] Functional Testing Collection Form Fields
Functional Testing Collection Form Fields
Mar 9, 2016
I've got an alternative approach which perhaps better mirrors what really happens - before obtaining the
Then a functional test just needs to add any dynamic form elements it needs before calling