function DrupalTestBrowser::addPostFields

Same name in other branches
  1. 9 core/tests/Drupal/Tests/DrupalTestBrowser.php \Drupal\Tests\DrupalTestBrowser::addPostFields()
  2. 10 core/tests/Drupal/Tests/DrupalTestBrowser.php \Drupal\Tests\DrupalTestBrowser::addPostFields()

Adds form parameters to the $multipart array.

Parameters

array $formParams: The form parameters.

array $multipart: A reference to the multipart array to add the form parameters to.

string $array_name: Internal parameter used by recursive calls.

1 call to DrupalTestBrowser::addPostFields()
DrupalTestBrowser::doRequest in core/tests/Drupal/Tests/DrupalTestBrowser.php

File

core/tests/Drupal/Tests/DrupalTestBrowser.php, line 213

Class

DrupalTestBrowser
Enables a BrowserKitDriver mink driver to use a Guzzle client.

Namespace

Drupal\Tests

Code

public function addPostFields(array $formParams, array &$multipart, $array_name = '') {
    foreach ($formParams as $name => $value) {
        if (!empty($array_name)) {
            $name = $array_name . '[' . $name . ']';
        }
        if (\is_array($value)) {
            $this->addPostFields($value, $multipart, $name);
        }
        else {
            $multipart[] = [
                'name' => $name,
                'contents' => $value,
            ];
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.