Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Explain submitWithAdditionalValues() usage#6403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletionsbook/testing.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -687,6 +687,39 @@ their type::
// Upload a file
$form['photo']->upload('/path/to/lucas.jpg');

If you use a :doc:`Collection of Forms </cookbook/form/form_collections>`,
you can't add fields to the existing form (this results in an error
``Unreachable field "…"``). You can use the `submitWithAdditionalValues()`
method in order to add new fields::

$crawler = $client->submitWithAdditionalValues(
$form,
array(),
// New values:
array('task[tags][0][name]' => 'tag1'),
);

// The tag has been added.
$this->assertEquals(1, $crawler->filter('ul.tags > li')->count());

Where ``task[tags][0][name]`` is the name of a field usually created
with Javascript.

You can remove an existing field, e.g. a tag::

// Get the values of the form.
$values = $form->getPhpValues();

// Remove the first tag.
unset($values['task']['tags'][0]);

// Submit the data.
$crawler = $client->request($form->getMethod(), $form->getUri(),
$values, $form->getPhpFiles());

// The tag has been removed.
$this->assertEquals(0, $crawler->filter('ul.tags > li')->count());

.. tip::

If you purposefully want to select "invalid" select/radio values, see
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp