Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractBrowser.php

function AbstractBrowser::submitForm

Finds the first form that contains a button with the given content and uses it to submit the given form field values.

Parameters

string $button The text content, id, value or name of the form <button> or <input type="submit">:

array $fieldValues Use this syntax: ['my_form[name]' => '...', 'my_form[email]' => '...']:

string $method The HTTP method used to submit the form:

array $serverParameters These values override the ones stored in $_SERVER (HTTP headers must include an HTTP_ prefix as PHP does):

File

vendor/symfony/browser-kit/AbstractBrowser.php, line 310

Class

AbstractBrowser
Simulates a browser.

Namespace

Symfony\Component\BrowserKit

Code

public function submitForm(string $button, array $fieldValues = [], string $method = 'POST', array $serverParameters = []) : Crawler {
    $crawler = $this->crawler ?? throw new BadMethodCallException(\sprintf('The "request()" method must be called before "%s()".', __METHOD__));
    $buttonNode = $crawler->selectButton($button);
    if (0 === $buttonNode->count()) {
        throw new InvalidArgumentException(\sprintf('There is no button with "%s" as its content, id, value or name.', $button));
    }
    $form = $buttonNode->form($fieldValues, $method);
    return $this->submit($form, [], $serverParameters);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal