Skip to content

Commit

Permalink
Reverted 2af62a1. Fixes Codeception#2238
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Aug 4, 2015
1 parent 9d06c20 commit ed6c350
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Codeception/Lib/InnerBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,22 593,28 @@ protected function getFormFor(Crawler $node)
/**
* Returns an array of name => value pairs for the passed form.
*
* The function calls getPhpValues on the passed form object, then
* resets numeric array indexes for array field names without array
* keys specified (i.e. 'fieldname[]' but not 'fieldname[keyname]')
* as expected by setCheckboxBoolValues.
* For form fields containing a name ending in [], an array is
* created out of all field values with the given name.
*
* @param \Symfony\Component\DomCrawler\Form the form
* @return array an array of name => value pairs
*/
protected function getFormValuesFor(Form $form)
{
$values = $form->getPhpValues();
$values = [];
$fields = $form->all();
foreach ($fields as $field) {
$name = $this->getSubmissionFormFieldName($field->getName());
if (!empty($values[$name]) && substr($field->getName(), -2) === '[]') {
$values[$name] = array_values($values[$name]);
$fieldName = $this->getSubmissionFormFieldName($field->getName());
if (!$field->hasValue()) {
continue;
}
if (substr($field->getName(), -2) === '[]') {
if (!isset($values[$fieldName])) {
$values[$fieldName] = [];
}
$values[$fieldName][] = $field->getValue();
} else {
$values[$fieldName] = $field->getValue();
}
}
return $values;
Expand Down

0 comments on commit ed6c350

Please sign in to comment.