_generated\AcceptanceTesterActions::submitForm PHP Method

submitForm() public method

Submits the given form on the page, optionally with the given form values. Give the form fields values as an array. Note that hidden fields can't be accessed. Skipped fields will be filled by their values from the page. You don't need to click the 'Submit' button afterwards. This command itself triggers the request to form's action. You can optionally specify what button's value to include in the request with the last parameter as an alternative to explicitly setting its value in the second parameter, as button values are not otherwise included in the request. Examples: php submitForm('#login', [ 'login' => 'davert', 'password' => '123456' ]); or $I->submitForm('#login', [ 'login' => 'davert', 'password' => '123456' ], 'submitButtonName'); For example, given this sample "Sign Up" form: html
Login:
Password:
Do you agree to our terms?
Select pricing plan:
You could write the following to submit it: php submitForm( '#userForm', [ 'user[login]' => 'Davert', 'user[password]' => '123456', 'user[agree]' => true ], 'submitButton' ); Note that "2" will be the submitted value for the "plan" field, as it is the selected option. Also note that this differs from PhpBrowser, in that 'user' => [ 'login' => 'Davert' ] is not supported at the moment. Named array keys *must* be included in the name as above. Pair this with seeInFormFields for quick testing magic. php 'value', 'field2' => 'another value', 'checkbox1' => true, ... ]; $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); $I->amOnPage('/path/to/form-page') may be needed $I->seeInFormFields('//form[@id=my-form]', $form); ?> Parameter values must be set to arrays for multiple input fields of the same name, or multi-select combo boxes. For checkboxes, either the string value can be used, or boolean values which will be replaced by the checkbox's value in the DOM. php submitForm('#my-form', [ 'field1' => 'value', 'checkbox' => [ 'value of first checkbox', 'value of second checkbox, ], 'otherCheckboxes' => [ true, false, false ], 'multiselect' => [ 'first option value', 'second option value' ] ]); ?> Mixing string and boolean values for a checkbox's value is not supported and may produce unexpected results. Field names ending in "[]" must be passed without the trailing square bracket characters, and must contain an array for its value. This allows submitting multiple values with the same name, consider: php $I->submitForm('#my-form', [ 'field[]' => 'value', 'field[]' => 'another value', // 'field[]' is already a defined key ]); The solution is to pass an array value: php this way both values are submitted $I->submitForm('#my-form', [ 'field' => [ 'value', 'another value', ] ]);
See also: Codeception\Module\WebDriver::submitForm()
public submitForm ( $selector, $params, $button = null )
$selector
$params
$button
    public function submitForm($selector, $params, $button = null)
    {
        return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args()));
    }
AcceptanceTesterActions